Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,213 members, 7,836,033 topics. Date: Tuesday, 21 May 2024 at 07:26 PM

Find The Error In This Mysql Statement. - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Find The Error In This Mysql Statement. (528 Views)

If You Are Using /blogger, Then You Must Read This Latest Error / How To Manage 403 Forbidden Error In Wordpress / Error "Com.digitalpersona.onetouch.jni.jniexception" (2) (3) (4)

(1) (Reply) (Go Down)

Find The Error In This Mysql Statement. by Nipeks(m): 6:19pm On Jun 11, 2015
I ran this MySQL query:


mysql_query("INSERT INTO replies(`post`, `date`, `last_modified`, `thread_id`, `replier_id`, `hidden`)
VALUES('".mysql_real_escape_string($post)."', '".mysql_real_escape_string($time)."',
'".mysql_real_escape_string($time)."', ".mysql_real_escape_string($thread_id).",
".mysql_real_escape_string($user_id).", 0"wink; echo mysql_error();

NB: The emoticon in the query is actually a closing bracket followed by a semi-colon.

And I get this error:

[b]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[/b]


I have been trying for some hours now and still couldn't find the syntax error. Pls, what am I doing wrong?
Re: Find The Error In This Mysql Statement. by JackOfAllTrades: 7:09pm On Jun 11, 2015
Just assign them(MySql_real_string() ) to a variable, the you can use double quotes without having to concatenate
Re: Find The Error In This Mysql Statement. by Adesege(m): 7:14pm On Jun 11, 2015
Instead of echo mysql_error(), immediately after the closing bracket of the query, put:

or die(mysql_error());

That should give you more error reporting
Re: Find The Error In This Mysql Statement. by Nipeks(m): 7:27pm On Jun 11, 2015
Thanks guys but I figured it out. This is this correct version:


mysql_query("INSERT INTO replies(`post`, `date`, `last_modified`, `thread_id`, `replier_id`, `hidden`)
VALUES('".mysql_real_escape_string($post)."', '".mysql_real_escape_string($time)."',
'".mysql_real_escape_string($time)."', ".mysql_real_escape_string($thread_id).",
".mysql_real_escape_string($user_id).", 0)"wink;



The VALUES() was missing a closing bracket.

1 Like

(1) (Reply)

What Is The Difference Between & Wordpress.org? / Need Active Adsense Account With Code Active Non- Hosted Account / Bloggers Abeg Pls I Need Your Asistance Pls Help

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.