PDA

View Full Version : Php not adding to table and no error


barkermn01
11-30-2007, 02:57 PM
$quest = $_POST['Quest'];
$a1 = $_POST['Answer1'];
$a2 = $_POST['Answer2'];
$a3 = $_POST['Answer3'];
$a4 = $_POST['Answer4'];
$a5 = $_POST['Answer5'];
$poster = $_POST['Poster'];
$id = $_POST['q_id'];
$con = mysql_connect('localhost', 'yawe_site', 'r5kjp9lk');
mysql_select_db('yawe_Site', $con);
if($id == ''){ $id = rand(1, 9999999);}
mysql_query('INSERT INTO `Polls` (`ID`, `Question`, `Answer_1`, `Answer_2`, `Answer_3`, `Answer_4`, `Answer_5`,
`Poster`, `Q_ID`) VALUES (NULL, \''.$quest.'\', \''.$a1.'\', \''.$a2.'\', \''.$a3.'\', \''.$a4.'\', \''.$a5.'\', \''.$poster.'\', \''.$id.'\');');
mysql_close($con);
echo mysql_error();
echo '<br>created poll';

Output from this is
<<<<<< This is a Line break
created poll

CFMaBiSmAd
11-30-2007, 03:54 PM
You should probably read your query statement, it clearly contains an error.

Also, none of your msyql_xxxxxx function calls contain any error checking or error reporting logic to get them to tell you if or why they don't work. The code examples in php manual for each of the mysql functions you are using includes some error checking and error reporting logic for you to use.

barkermn01
11-30-2007, 04:00 PM
Sorry That was my fault coz i had built it by hand the first time and it dint work so i used a template from phpmyadmin to get it to work must have copyed and pasted wroung i will try fixing then posting back if it works or not

********** EDIT ****************
Works Ty Wounder what i did wrong the first time
o Well Thanks for your help