PHP 'submit' cannot link with mysql
Moderator: General Moderators
PHP 'submit' cannot link with mysql
solved
Last edited by alvintiow on Fri May 09, 2008 2:53 am, edited 1 time in total.
Re: PHP 'submit' cannot link with mysql
Don't use @ to suppress errors in scripts you're trying to debug. You need those errors to tell you why things aren't working.
Re: PHP 'submit' cannot link with mysql
Hi, Thanks for reply, but any recommended for making the coding working?
Re: PHP 'submit' cannot link with mysql
remove the @ sign and pass the error message displayed.
Re: PHP 'submit' cannot link with mysql
Try this and see if there's an error
Code: Select all
//link up to mysql database
$host = "localhost";
$user = "root";
$password = "";
$dbname = "agilent";
$table = "customerorder";
$link = mysql_connect($host, $user, $password) or die ("Connection: " . mysql_error() . mysql_errno());
mysql_select_db($dbname, $link) or die ("Database: " . mysql_error() . mysql_errno());
//if an entry has been submitted add it to the database
if (isset($_POST['submit'])) {
$result = mysql_query("INSERT INTO customerorder
(
model,
serialnumber,
caldate,
duedate,
assetid
) VALUES (
'".mysql_real_escape_string($_POST['model'])."',
'".mysql_real_escape_string($_POST['serialnumber'])."',
'".mysql_real_escape_string($_POST['caldate'])."',
'".mysql_real_escape_string($_POST['duedate'])."',
'".mysql_real_escape_string($_POST['assetid'])."'
)
");
if (!$result) {
die('Error in query: ' . mysql_error() . mysql_errno());
} else {
echo "<p align=\"center\"><font color=\"#9966FF\" size=\"4\" face=\"Arial Black\">We have received the following details already,thank you for your support. </font></p>";
echo "<p align=\"left\"><font size=\"2\" face=\"Arial Black\">Model: <b>".$_POST['model']."</b><br/></font></p>";
echo "<p align=\"left\"><font size=\"2\" face=\"Arial Black\">Serial Number: <b>".$_POST['serialnumber']."</b><br/></font></p>";
echo "<p align=\"left\"><font size=\"2\" face=\"Arial Black\">Calculate Date: <b>".$_POST['caldate']."</b><br/></font></p>";
echo "<p align=\"left\"><font size=\"2\" face=\"Arial Black\">Due Date: <b>".$_POST['duedate']."</b><br/></font></p>";
echo "<p align=\"left\"><font size=\"2\" face=\"Arial Black\">Asset ID: <b>".$_POST['assetid']."</b><br/></font></p>";
}
}
Re: PHP 'submit' cannot link with mysql
my problem solved, thank for helping Tongue, everything works fine, but I should not open my webpage directly, I should open it as http://localhost/abc.php