please help me..
kindly see if what's wrong with my code below.. im trying to insert values in a table on my database but the query returned as failed.
[php]
html code -my input page
<form action="addcust omers.php" method="$_POST" >
Customer ID: <input type="text" name="CustID">< br>
Name: <input type="text" name="Name"><br >
Address: <input type="text" name="Address"> <br>
Credit Limit:<input type="text" name="CreditLim it"><br>
<input type="submit" value="ADD">
php code-to process my html code
<?php
$id = $_POST['CustID'];
$name=$_POST['Name'];
$address=$_POST['Address'];
$creditlimit=$_ POST['CreditLimit'];
$con=mysql_conn ect('localhost' ,'root','my_pas sword');
$db=mysql_selec t_db('hsrc',$co n);
$query_string=" INSERT INTO customer VALUES ($id,'$name','$ address',$credi tlimit)";
echo $query_string;
$query=mysql_qu ery($query_stri ng);
if($query)
{
echo"customers record successfully added";
}else
{
echo"adding of customers record failed";
}
?>
php code -use to display added values in the table
$con = mysql_connect(' localhost','roo t','my_password ');
$db = mysql_select_db ('hsrc',$con);
$str = "SELECT * FROM customer";
$query = mysql_query($st r);
echo("<table border=1>");
echo("<tr><td>C ustomer ID</td><td>Name</td><td>Address</td><td>CreditLi mit</td></tr>");
while($val=mysq l_fetch_array($ query))
{
echo "<tr><td>" . $val['CustID'] . "</td><td>" . $val['Name'] . "</td><td>" . $val['Address']."</td><td>" . $val['CreditLimit'] . "</td><td>" . $val['DepotID'] . "</td></tr>";
}
echo "<table>";
?>.[/php]
kindly see if what's wrong with my code below.. im trying to insert values in a table on my database but the query returned as failed.
[php]
html code -my input page
<form action="addcust omers.php" method="$_POST" >
Customer ID: <input type="text" name="CustID">< br>
Name: <input type="text" name="Name"><br >
Address: <input type="text" name="Address"> <br>
Credit Limit:<input type="text" name="CreditLim it"><br>
<input type="submit" value="ADD">
php code-to process my html code
<?php
$id = $_POST['CustID'];
$name=$_POST['Name'];
$address=$_POST['Address'];
$creditlimit=$_ POST['CreditLimit'];
$con=mysql_conn ect('localhost' ,'root','my_pas sword');
$db=mysql_selec t_db('hsrc',$co n);
$query_string=" INSERT INTO customer VALUES ($id,'$name','$ address',$credi tlimit)";
echo $query_string;
$query=mysql_qu ery($query_stri ng);
if($query)
{
echo"customers record successfully added";
}else
{
echo"adding of customers record failed";
}
?>
php code -use to display added values in the table
$con = mysql_connect(' localhost','roo t','my_password ');
$db = mysql_select_db ('hsrc',$con);
$str = "SELECT * FROM customer";
$query = mysql_query($st r);
echo("<table border=1>");
echo("<tr><td>C ustomer ID</td><td>Name</td><td>Address</td><td>CreditLi mit</td></tr>");
while($val=mysq l_fetch_array($ query))
{
echo "<tr><td>" . $val['CustID'] . "</td><td>" . $val['Name'] . "</td><td>" . $val['Address']."</td><td>" . $val['CreditLimit'] . "</td><td>" . $val['DepotID'] . "</td></tr>";
}
echo "<table>";
?>.[/php]
Comment