Jump to content

[SOLVED] getting a syntax error with mysql


smartin1017

Recommended Posts

I am running into a syntax error. I know this is right but it wont work. I have a table called 'dark_hunter', in that table i have a cloumn called 'book_title'. When someone clicks the image bookcover (there are seven bookcovers on the page) it brings them to the 'bookdisplay' page where the book title and series is appended to the URL, I $_GET them and use that in my DB query.

 

This is my query

 

$result = mysql_query("SELECT * FROM $bookseriesfordisplay WHERE book_title = `$booktitlefordisplay`")

 

$bookseriesfordisplay is the series and $booktitlefordisplay is the title. I know these work because I did a little checking and echoed them out so I know the correct info is passing. Here is the error..

 

Unknown column 'dragonswan' in 'where clause'

 

dragonswan is the book_title passed over the URL.

 

Any ideas?

Link to comment
Share on other sites

try this

 

$result = mysql_query("SELECT * FROM '$bookseriesfordisplay' WHERE book_title = '$booktitlefordisplay'");

 

it is saying that in the table there is no book_title called 'dragonswan', i have placed single ticks around the php variables because they have to have that for the query to work and you didnt have any around the FROM variable

Link to comment
Share on other sites

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.