Jump to content

Recommended Posts

I'm setting up a book database and have a page for photos of authors, where visitors can click on the photo and go through to a page with more information. The table I'm drawing from is TitleInfo with num, title, author_first, author_last, isbn. I set up a similar code for book covers and that works fine, but I adapted it and it no longer works. When the link clicks through, it says "Unknown column '(author's last name)' on line 13." I know that the column exists. How do I make it work? Help!

 

Here's the code for the link

 

<?

include("connect.php");

$sql=mysql_query("SELECT * FROM AuthorInfo ORDER BY last") or die ('Error: '.mysql_error());

while($r=mysql_fetch_array($sql))
{
    $lname=$r['last'];
        
    echo "<a href='authorss.php?type=$lname'>";
    echo "<img src='images/" . $lname . ".jpg' hspace=5 vspace=5 border=0 height=200 align='left'>";
    echo "</a>";
}

?>

 

Here's the code for authorss.php (I know right now it's really simplistic, but I need the page to get the information before I start designing, etc):

 

<?

include("connect.php");

$v=$_GET['type'];

$query=mysql_query("SELECT * FROM AuthorInfo WHERE last=$v") or trigger_error (mysql_error());

while($r=mysql_fetch_array($query))
{
    $v1=$r["last"];
    echo $v1;
    echo "<br>";
}

?>

 

Help! Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/185160-_get-code-in-link-not-working/
Share on other sites

im assuming that the `last` column is a varchar type

("SELECT * FROM AuthorInfo WHERE last='$v'");

 

try that, you have to surround strings in mysql with quotes, or else it thinks its a number/variable/keyword/something its not

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.