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 11 of 11
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    A href tag and Mysql qery (Master page)

    Hello.
    trying to put a variable trough an URL, $_GET but at this point have an error.
    Code:
    echo "<td><a href="movie_details.php?art_desc=$art_desc"
    			title="Find out more about $art_desc><" . $art_desc . "></td>;
    Code:
    Parse error: parse error, expecting `','' or `';'' in D:\Program Files\EasyPHP 3.0\www\com\gallery.php on line 33
    obviously something , or ; misses up but where?

  • #2
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You're using "double quotes" to wrap your string, and within your string. Either escape the quotes in the string using a backslash, e.g.
    PHP Code:
    $var"sometimes I like to use \"double quotes\" in quoted strings"
    Or simply use 'single quotes' within the string itself.

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    something like this
    Code:
    echo "<td><a href=showart.php?art_desc='.$art_desc.'</a></td>\n";
    tried also
    Code:
     echo "<td><a href=showart.php?art_desc=\".$art_desc.\"</a></td>\n";
    no errors but the column $art_desc doesn't display

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    echo "<td><a href=showart.php?art_desc=".$art_desc."</a></td>\n"
    Or
    PHP Code:
    echo "<td><a href=showart.php?art_desc=\"$art_desc\"</a></td>\n"
    Or more precisely
    PHP Code:
    echo "<td><a href=showart.php?art_desc=\"{$art_desc}\"</a></td>\n"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Jun 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    tried but no the column $art_desc doens't display

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Please post your updated code. Its likely you did something wrong.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #7
    New Coder
    Join Date
    Jun 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    <html>
    <head>
    <title>Welcome to our Photo Gallery</title>
    </head>
    <body>
    <p align="center">Click on any image to see it full sized.</p>
    <table width="60%" border="0" cellpadding="2" 
           cellspacing="2" align="center">
      <tr>
        <td align="left">Image</td>
        <td align="left">Description</td>
        <td align="left">Categoria</td>
        </tr>
    <?php
    require_once ("misc.php");
    require_once (
    "Connexion.php");
    require_once (
    "ExecRequete.php");  
      
    $connexion Connexion(NOMPASSEBASESERVEUR);
    $result ExecRequete("SELECT ALL artigos.*, cat_nome FROM artigos INNER JOIN categorias ON artigos.cat_id = categorias.cat_id"$connexion);
    while (
    $rows mysql_fetch_array($result)) {
      
    extract($rows);
      echo 
    "<tr>\n";
      echo 
    "<td><a href='../images/{$rows['art_nome']}'
                               border='0'>
                <img src='../images/{$rows['art_nome']}' border='0'
                  width='100' height='80'></a></td>\n"
    ;
      echo 
    "<td><a href=showart.php?art_desc=\"{$art_desc}\"</a></td>\n"
      echo 
    "<td>" $cat_nome "</td>\n";
      echo 
    "</tr>\n";
    }
    ?>
    </table>
    </body>
    </html>
    no errors on displaying the page just the column $art_desc won't display
    Last edited by Cyber_type; 04-29-2009 at 10:21 AM.

  • #8
    New Coder
    Join Date
    Jun 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    tried this

    PHP Code:
    while ($rows mysql_fetch_array($result)) {
      
    //extract($rows);
      
      
    $art_nome $rows['art_nome'];
      
    $art_desc $rows['art_desc']; 
      
    $cat_nome $rows['cat_nome'];
      
      echo 
    "<tr>\n";
      echo 
    "<td><a href='../images/{$rows['art_nome']}'
                               border='0'>
                <img src='../images/{$rows['art_nome']}' border='0'
                  width='100' height='80'></a></td>\n"
    ;
                  echo 
    "<td><a href=showart.php?art_desc=\"{$art_desc}\"</a></td>\n";  
      echo 
    "<td>" $cat_nome "</td>\n";
      echo 
    "</tr>\n";

    trying the variables with "echo $art_nome" and so it display it but with the <a href> tag it won't.

  • #9
    New Coder
    Join Date
    Jun 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    tried to pu an echo between the <a></a> tag but nothing
    PHP Code:
    echo "<td><a href=showart.php?art_desc= echo " .$art_desc"</a></td>\n"
    someone have an idea?

  • #10
    New Coder
    Join Date
    Jun 2007
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Done!!
    Here's the good code
    PHP Code:
    echo '<td><a href="showart.php?art_desc='.$art_desc.'">'.$art_desc."</a></td>\n"

  • #11
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    @Cyber_type> I'm glad you sorted it out. Do you see the mistakes you were making there?

    I strongly suggest, before you go much further, that you take the time to sit and read through the PHP Language Reference, especially the sections on Types, Variables and Operators.


  •  

    Posting Permissions

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