Whats wrong ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

Whats wrong ??

Post by winsonlee »

Failed to execute query: Unknown column 'Helllo' in 'field list'

That is the error msg that i get in my following code. I would like to know what goes wrong with it.

Code: Select all

$title = $_POSTї'title'];
$message = $_POSTї'yourFieldNameHere'];
$datex = time();

$result = database("INSERT INTO `xoops_weblog` ( `blog_id` , `user_id` , `cat_id` , `created` , `title` , `contents` , `private` , `comments` , `reads` , `description` , `dohtml` ) VALUES ('', '1', '2', $datex, $title, 'hello', 'N', '0', '0', '', '0')");
leenoble_uk
Forum Contributor
Posts: 108
Joined: Fri May 03, 2002 10:33 am
Location: Cheshire
Contact:

Post by leenoble_uk »

Code: Select all

$title = $_POSTї'title']; 
$message = $_POSTї'yourFieldNameHere']; 
$datex = time(); 

$result = database("INSERT INTO xoops_weblog ( blog_id , user_id , cat_id , created , title , contents , private , comments , reads , description , dohtml ) VALUES ('', '1', '2', '$datex', '$title', 'hello', 'N', '0', '0', '', '0')");
I assume database() is a function which processes the query.
Last edited by leenoble_uk on Wed May 19, 2004 10:49 am, edited 1 time in total.
dave420
Forum Contributor
Posts: 106
Joined: Tue Feb 17, 2004 8:03 am

Post by dave420 »

Have you tried putting your $variables ($datex and $title) in backticks?
leenoble_uk
Forum Contributor
Posts: 108
Joined: Fri May 03, 2002 10:33 am
Location: Cheshire
Contact:

Post by leenoble_uk »

Also MySQL can create the timestamp itself instead of using the PHP variable.

Code: Select all

"INSERT INTO xoops_weblog ( blog_id , user_id , cat_id , created , title , contents , private , comments , reads , description , dohtml ) VALUES ('', '1', '2', UNIX_TIMESTAMP(NOW()), '$title', 'hello', 'N', '0', '0', '', '0')"
Post Reply