SQL Syntax Error
Posted: Sun Oct 31, 2004 10:47 pm
I'm trying this code feyd helped me with a few weeks ago. I'm not sure if this is a syntax error or if my mysql version is too old.
When I run the code just like that, it comes back with "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 'BETWEEN 1 AND 36' at line 1"
My server's php version is 4.3.9
and my mysql version is 4.0.22-standard-log
Code: Select all
<?php
$db = '';
$user = '';
$pw = '';
$mysql_access = mysql_connect("localhost", $user, $pw);
mysql_select_db($db, $mysql_access);
$date = date("Ymj");
$rows = array();
$query = mysql_query('SELECT id,url,text FROM zlinks WHERE cat IS BETWEEN 1 AND 36') or die(mysql_error());
while($rows[] = mysql_fetch_assoc($query));
array_pop($rows);
$inserted = array();
$size = sizeof($rows);
while(sizeof($inserted) != $size)
{
while(!in_array($inserted,$which = mt_rand(1,36)) && isset($rows[$which]));
$sql = 'INSERT ' . 'INTO' . ' zlink1 (oid, date, url, text) VALUES(''' . $rows[$which]['id'] . ''', ''' . $date . ''', ''' . $rows[$which]['url'] . ''', ''' . $rows[$which]['text'] . ''')';
if(!mysql_query($sql)) break;
$inserted[] = $which;
}
?>My server's php version is 4.3.9
and my mysql version is 4.0.22-standard-log