Jump to content

sql error ?


Alicia

Recommended Posts

Hi,

 

I encounter this error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

on this query :

$result = mysql_query("SELECT * FROM `vrequest` WHERE `type`='student now' AND `to`='$id'") or die(mysql_error());

 

I have checked multiple times and really have no idea whats wrong with this simple query.

 

please advise.

Link to comment
Share on other sites

well...i don't see anything semantically wrong with your code. again, do the print $sql code to make sure the value of $id is what you expect. also, try changing this:

die(mysql_error());

to something more distinguishing:

die("Failed to SELECT from vrequest: ".mysql_error());

just to make sure that is the actual point of failure

Link to comment
Share on other sites

well...there is nothing wrong with the code you posted. further remediation:

 

1) Make sure you are definitely looking at the place where the problem is

2) Make sure your quotes are copied from MS Word...it uses different quotes. Just to be safe, open the file in a basic text editing (like notepad), then delete each quote and type it back in...just to make sure. it sounds silly, but a lot of problems are caused by this.

Link to comment
Share on other sites

Unless $id contained something with a single-quote in it, nothing you have posted so far would generate that error.

 

Does your code contain any other queries and what is the code that produces $id, both originally in your form or link and how is it processed before being put into the query? Show all your code to get the quickest solution.

Link to comment
Share on other sites

thats all I have in my script with

$id ='1';

 

tried

$id ="1";

 

$id =1;

 

still showing the same error even i replaced * with column names and remove the where clause...

 

a simple query like select * from vrequest caused the same error too.. oh gosh, what happened to my computer,, is it computer prob or what

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.