PHP 'submit' cannot link with mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alvintiow
Forum Newbie
Posts: 3
Joined: Mon Apr 28, 2008 5:24 am

PHP 'submit' cannot link with mysql

Post by alvintiow »

solved
Last edited by alvintiow on Fri May 09, 2008 2:53 am, edited 1 time in total.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP 'submit' cannot link with mysql

Post 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.
alvintiow
Forum Newbie
Posts: 3
Joined: Mon Apr 28, 2008 5:24 am

Re: PHP 'submit' cannot link with mysql

Post by alvintiow »

Hi, Thanks for reply, but any recommended for making the coding working?
User avatar
louie35
Forum Contributor
Posts: 144
Joined: Fri Jan 26, 2007 8:40 am
Location: Dublin
Contact:

Re: PHP 'submit' cannot link with mysql

Post by louie35 »

remove the @ sign and pass the error message displayed.
User avatar
lafever
Forum Commoner
Posts: 99
Joined: Sat Apr 05, 2008 2:03 pm
Location: Taylor, MI

Re: PHP 'submit' cannot link with mysql

Post 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>";
 
    }
 
 
}
 
alvintiow
Forum Newbie
Posts: 3
Joined: Mon Apr 28, 2008 5:24 am

Re: PHP 'submit' cannot link with mysql

Post 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
Post Reply