Some mySQL syntax that can lead to broken code

Report bugs and errors in this forum.

Some mySQL syntax that can lead to broken code

Postby BadDog » Tue Jan 03, 2006 11:14 pm

I have a few suggestions for correcting some bugs here, mainly have to do with mySQL syntax that breaks under current mySQL versions. Example, comments were not being added because of this code:



Code: Select all

$sql->insert(array(

'table'    => 'comments',

'values' => array(

         'post_id' => $id,

         'date'     => $time,

         'author'  => $name,

         'mail'     => $mail,

         'ip'     => $_SERVER['REMOTE_ADDR'],

         'comment' => $comments

         )

));







The fix was to use this code instead:



Code: Select all



'table'  => 'comments',

'values' => array(

             'date'    => $time,

             'author'  => $name,

             'mail'    => $mail,

             'ip'      => $_SERVER['REMOTE_ADDR'],

             'comment' => $comments,

             'reply' => $reply,

             'post_id' => $id)

));





The same thing with adding news, the actual table fields are not in the same order as the insert script that adds the news, newer mySQL defaults do not like this!



half of my news imports was rejected because url and title in news table was string type and not text type. Very bad, use TEXT TYPE for url and title in news table to avoid all possible errors!!!!!!



Another strange thing I noticed was the index ID for news table starts with 1 and story table starts with index 0 during convert. Not good!
BadDog
 
Posts: 62
Joined: Mon Nov 21, 2005 8:19 am

Return to Bugs and errors



Who is online

Users browsing this forum: No registered users and 0 guests

cron