Page 1 of 1

PHP 'submit' cannot link with mysql

Posted: Mon Apr 28, 2008 5:27 am
by alvintiow
solved

Re: PHP 'submit' cannot link with mysql

Posted: Mon Apr 28, 2008 5:40 am
by onion2k
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

Posted: Mon Apr 28, 2008 8:35 am
by alvintiow
Hi, Thanks for reply, but any recommended for making the coding working?

Re: PHP 'submit' cannot link with mysql

Posted: Mon Apr 28, 2008 8:41 am
by louie35
remove the @ sign and pass the error message displayed.

Re: PHP 'submit' cannot link with mysql

Posted: Mon Apr 28, 2008 10:15 am
by lafever
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

Posted: Tue Apr 29, 2008 11:33 am
by alvintiow
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