...

View Full Version : syntax or wrong way.



mivec
04-16-2004, 12:16 PM
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.






<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:






$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

mordred
04-16-2004, 12:22 PM
Your link contains too many double quotes. I reckon it should rather be:



<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, I find it strange that you put a space before and after the user name. Is that intentional?

Debugging tip: Always look at the generated HTML code, and print out SQL queries you have problems with. It's kinda hard figuring out how PHP generates output once things get complex.

mivec
04-16-2004, 01:22 PM
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:






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...

Garadon
04-16-2004, 01:45 PM
u should not put " around the parameter values in the links href


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> ');



and as mentioned is those spaces intentional.

as it stands it searches the db for username that starts and ends with a space and has the send username between.

mordred
04-16-2004, 01:49 PM
Better post the modified code where you included my suggestion (which works, by the way). The code you posted above contains a parse error.

Hyder Ali
04-16-2004, 01:56 PM
Hi,
Try this and see if this works. If you put a double quote marks in a echo statement put a backlash first.

<?php

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>";
?>

Hyder

mordred
04-16-2004, 02:11 PM
No Hyder Ali, you are repeating the same error. There should not be a double quote before the value of username, this would "close" the attribute value of href, and thus cut off the username completely. Only the double quote after the username is needed. And that's what I suggested.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum