Current location: Hot Scripts Forums » Programming Languages » PHP » syntax problem


syntax problem

Reply
  #1 (permalink)  
Old 04-16-04, 06:14 AM
mivec mivec is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
syntax problem

hi all,
i am not sure if this syntax is correct for the following page where it is called..the value was not passed. here is the code.

PHP Code:

<td width="82%"><font face="Arial, Helvetica, sans-serif" size="2" color="#104071"><a href="photoUpload.php?mode=list&username="'.$_POST["txtUserID"].'"">-Upload New Photo</a></font></td
and the other page calling the $_POST value is:

PHP Code:

 $sql "SELECT * FROM tblgallery WHERE username = ' " $_GET["username"] . " ' ";
   
$rs mysql_query($sql);
   
$nRows mysql_num_rows($rs); 
could someone pls help?i dunno if it's syntax error at the a href area or i can't use that kinda way to call it. there are no forms included here as u can see...thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-16-04, 06:34 AM
the_mole001's Avatar
the_mole001 the_mole001 is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Australia
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Hello mivec,

I think your problem is in your href:

You have:
<a href="photoUpload.php?mode=list&username="'.$_POST["txtUserID"].'"">

However I think you want:
<a href="photoUpload.php?mode=list&username=".$_POST["txtUserID"]."">

Note i removed 2 ' s from where u were inserting the $_POST variable. I think instead of sedning a desired number such as 1 it was send '1' which the db might now of been able to find, returning no results.

Peter
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-16-04, 06:36 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
how many times do I have to answer this ? (j/k)
as I said before ... remove the last double quote in the href tag .. to this:
PHP Code:

echo'<td width="82%"><font face="Arial, Helvetica, sans-serif" size="2" color="#104071"><a href="photoUpload.php?mode=list&username='.$_POST['txtUserID'].'">-Upload New Photo</a></font></td>'
but if you were using quoble quotes from the begining of the printing process you need to escape them !
PHP Code:

echo"<td width=\"82%\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"#104071\"><a href=\"photoUpload.php?mode=list&username=".$_POST['txtUserID']."\">-Upload New Photo</a></font></td>"
and in your sql query, don't put spaces before and after the variable value !
PHP Code:

$sql "SELECT * FROM tblgallery WHERE username='{$_GET['username']}'"
this one should work .. just don't open with double quotes and attempt to close it with single quotes !!
and note that you are using GET not POST !!
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 04-16-04 at 06:42 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-16-04, 07:21 AM
mivec mivec is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the reply...sometimes i get confused about the double quotes and the single quotes on when or how to use them.....so sorry ler.but anyway..i have tried ur ways but it didn't work too...mebbe i should try posting u the whole thing. here it is:

PHP Code:

echo('<tr bgcolor="#FEDCED"> 
          <td width="12%">&nbsp;</td>
          <td width="6%">&nbsp;</td>
          <td width="82%"><font face="Arial, Helvetica, sans-serif" size="2" color="#104071"><a href="photoUpload.php?mode=list&username="'
.$_POST["txtUserID"].'"">-Upload New Photo</a></font></td>'); 
    </
tr
the sql query remains the same. tried ur way but didn't work...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Include Problem DAL Perl 3 11-20-04 08:45 AM
activation key problem dcooldude_1 PHP 0 04-02-04 04:58 PM
I have a problem... ICE Flame PHP 4 03-20-04 02:48 PM
Error: Syntax error converting datetime from character string. Han84 ASP 1 08-22-03 05:59 AM
jpGraph axis labeling problem Squeezer PHP 2 08-20-03 08:53 AM


All times are GMT -5. The time now is 11:42 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.