Forum Moderators: coopster

Message Too Old, No Replies

possible mysql error

can't find the problem

         

WhosAWhata

7:21 pm on Dec 3, 2005 (gmt 0)

10+ Year Member



This code is returning an error and I con't figure out why

error:

Parse error: parse error, unexpected '\"' in /home/user/public_html/temp/createpoll.php on line 11

code:

<?
if($submit == "Create!"){
$dbh = mysql_connect("localhost","heretic_member","language") or die('Cannot connect to the database.');
mysql_select_db("heretic_polls");
$q = "SELECT * FROM count WHERE 1=1 ORDER BY total";
$nums = mysql_query($q);
$d = mysql_fetch_assoc($nums);
$num = $d['total'];
$q = "INSERT INTO count ( total) VALUES ('".($num+1)."')';
$d = mysql_query($q);
$qtable = $num . "-questions";
$atable = $num . "-answers";
$sql = 'CREATE TABLE `$qtable` ( `num` INT NOT NULL, `code` LONGTEXT NOT NULL )';
$d = mysql_query($sql);
$sql = 'CREATE TABLE `$atable` ( `vote` INT NOT NULL, `ip` MEDIUMTEXT NOT NULL )';
$d = mysql_query($sql);
$q = "INSERT INTO master ( num, title, desc, question, count) VALUES ('$num','$title', '$desc', '$question', '$count')";
$d = mysql_query($q);
for($i=1; $i<=$count; $i++){
$q = "INSERT INTO $qtable ( num, code) VALUES ('$i', 'ans".$i."')";
}
} else{
//show form
}
?>

jatar_k

10:13 pm on Dec 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



mismatched quotes on this line

$q = "INSERT INTO count ( total) VALUES ('".($num+1)."')';