Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    syntax or wrong way.

    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
    Warm Regards,
    Mivec

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your link contains too many double quotes. I reckon it should rather be:

    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 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.
    De gustibus non est disputandum.

  • #3
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    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...
    Warm Regards,
    Mivec

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    u should not put " around the parameter values in the links href
    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>  '); 
    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.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Better post the modified code where you included my suggestion (which works, by the way). The code you posted above contains a parse error.
    De gustibus non est disputandum.

  • #6
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax

    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

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    De gustibus non est disputandum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •