Welcome Guest, Not a member yet? Register   Sign In
db->query HELP :(
#7

[eluser]Linderman[/eluser]
Hello! Thank you all for your replies! You great

I tried everything you said but i still got this problem. Finally i made it with theprodigy and Kenshiro advices and it works!!! It seems that some of column name is reserved word in MYSQL, but when i back ticking the column names .. the problem is GONE...

One more time , thank you all, Respect \/

the final solution:
[quote author="theprodigy" date="1273011851"]Apart from what has already been said, you may want to consider back-ticking the column names (this is part of the "escaping" that carvingCode mentioned). By back-ticking (`) the column names, this will make sure that if any of your column names are mysql reserved words, it recognizes them as column names and doesn't try to render whatever command they happen to be a part of.

Using Kenshiro's updated syntax, change:

Code:
$query = 'INSERT INTO ci_images (imagetype, usage, usage_id, size_num, size, name, fullpath, comment) VALUES ( "'.$data[imagetype].'", "'.$data[usage].'", '.$data[usage_id].', '.$data[size_num].', "'.$data[size].'", "'.$data[name].'", "'.$data[fullpath].'", "'.$data[comment].'")';
to:
Code:
$query = 'INSERT INTO ci_images (`imagetype`, `usage`, `usage_id`, `size_num`, `size`, `name`, `fullpath`, `comment`) VALUES ( "'.$data[imagetype].'", "'.$data[usage].'", '.$data[usage_id].', '.$data[size_num].', "'.$data[size].'", "'.$data[name].'", "'.$data[fullpath].'", "'.$data[comment].'")';
[/quote]


Messages In This Thread
db->query HELP :( - by El Forum - 05-04-2010, 05:21 AM
db->query HELP :( - by El Forum - 05-04-2010, 05:43 AM
db->query HELP :( - by El Forum - 05-04-2010, 05:50 AM
db->query HELP :( - by El Forum - 05-04-2010, 07:35 AM
db->query HELP :( - by El Forum - 05-04-2010, 10:56 AM
db->query HELP :( - by El Forum - 05-04-2010, 11:24 AM
db->query HELP :( - by El Forum - 05-04-2010, 01:15 PM
db->query HELP :( - by El Forum - 05-04-2010, 02:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB