I'm trying to build the online survey from the article "Creating an Online Survey " and I'm getting this error message
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /var/www/html/process_db.php on line 16
Error!
There was an error processing your request. mySQL returned the following:
the code:
<?php
$dbc = mysql_connect("localhost", "user", "password", "database");
if(!$dbc)
{
die('<span style="color: #F00; font-weight: bold;">Error!</span><br />There was error connecting. mySQL returned the following:<br /><br />'.mysql_connect_errno().'<br />'.mysql_connect_error());
}
$g = Array('male' => '0', 'female' => '1');
$a = Array('0_8' => '0', '9_16' => '1', '17_24' => '2', '25_32' => '3', '33_40' => '4', '41_x' => '5');
$st = Array('email' => '0', 'phone' => '1');
$k = Array('little' => '0', 'some' => '1', 'lots' => '2', 'expert' => '3');
$__r = Array('yes' => '0', 'no' => '1');
$sql = "INSERT INTO `onlinesurvey' (gender, age, suptype, knowledge, speed, repknowledge, results, personability, recommend) VALUES ('".$g[$POST['gender']]."', '".$a[$POST['age']]."', '".$st[$POST['suptype']]."', '".$k[$POST['knowledge']]."', '".$POST['speed']."', '".$POST['repknowledge']."', '".$POST['results']."', '".$POST['personability']."', '".$__r[$_POST['recommend']]."')";
$rslt = mysql_query($dbc, $sql);
if(!$rslt)
{
die('<span style="color: #F00; font-weight: bold;">Error!</span><br />There was an error processing your request. mySQL returned the following:<br /><br />'.mysql_errno($dbc).'<br />'.mysql_error($dbc));
}
Thanks for the help
Ryan