PDA

View Full Version : php form help


pats
12-11-2002, 06:56 PM
Hi I am having a problem with the following php form:
<html>
<body>
<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO email VALUES ('$firstname','$lastname','$company','$address1','$address2','$city','$state','$email','$interest1', '$interest2','$interest3','$interest4','$interest5','$interest6','$interest7')";
mysql_query($query);

mysql_close();

printf("<center><h3>OPT IN EMAIL LIST</h3><p><font size=-1>Thank you for taking the time to fill out the form. You will hear from us soon.");

?>

</body></html>



This is not writing into the MYSQL database.



The form is attached:

HormonX
12-11-2002, 07:27 PM
try echoing your MySQL query to see where it fails ..

HormonX

pats
12-11-2002, 08:16 PM
Thanks HormonX,

Well this form was working erlier; it just stopped writing to the table. I did not make any changes...

Well I will try and test it.
Thanks,

Pats...:(

mordred
12-11-2002, 08:28 PM
The SQL query should give you a hint what variables were actually passed to the query. I would advise you to also check whether MySQL reported any errors, because these error messages can be quite telling:


$result = mysql_query($query);

if ($result) {
echo "query was ok";
} else {
echo "query did not work, reason: ";
echo mysql_error();
}


That should help you work out your error.

BTW, is this correct syntax? Have you a constant named "localhost" defined?


mysql_connect(localhost,$username,$password);
//^^^^^^^^^ looks strange


Good luck!