Forum Moderators: coopster
Code is the following
<?php
//connect to server and select database
$mysql = mysql_connect("server","username","password");
//if connection connection fails
if (mysql_connect_error()) {
echo "connection failure";
exit();
//insert into table
} else {
$sql = "INSERT INTO email (email) VALUES
'".$POST["email"]."',";
$res = mysql_query(mysql,$sql);
}
//success or failed message
if ($res === TRUE) {
echo "A record has been inserted";
} else {
echo "Could not insert record:%s\n" mysql_error(mysql);
mysql_close(mysql);
}
?>
line 19 is
echo "Could not insert record:%s\n" mysql_error(mysql);
can anybody help?
Cheers
[edited by: shaundunne at 10:35 am (utc) on Dec. 27, 2007]
[edited by: coopster at 2:36 pm (utc) on Dec. 27, 2007]
[edit reason] exemplified username/password [/edit]
echo "Could not insert record:%s\n" mysql_error(mysql);
sprintf('Could not insert record:%s\n', mysql_error(mysql));
// OR
echo 'Could not insert record:'.mysql_error(mysql)."\n";
// OR
echo "Could not insert record:mysql_error(mysql)\n";
Your original echo doesnt accept placeholders like the sprintf [uk.php.net]if you would like to keep with the %s version of printing.