Jump to content

sql problem


mworkman

Recommended Posts

I have having a problem getting a mysql query to work.

 

If I just use mysql_query it looks like this and works fine:

INSERT INTO schedule (schedule_pk, schedule_month, schedule_day, schedule_year, schedule_hour, schedule_minute, schedule_type, employeenumber) VALUES ( NULL, 10, 10, 1999, 12, 6, 'DayIn', 3);

 

If I put it through mysql_real_escape_string it turns it to this and does not work when I put it into mysql_query:

INSERT INTO schedule (schedule_pk, schedule_month, schedule_day, schedule_year, schedule_hour, schedule_minute, schedule_type, employeenumber) VALUES ( NULL, 10, 10, 1999, 12, 6, \'DayIn\', 3);

 

aka:

$query = "INSERT INTO...."

mysql_query($query);

 

that works, but:

$query = "INSERT INTO...."

$sqlQuery = mysql_real_escape_string($query, $con);

mysql_query($sqlQuery);

 

results in the error.

mysql_query($query);

 

 

The error is:

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 '\'DayIn\', 3)' at line 1

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.