hisham
IS-IT--Management
- Nov 6, 2000
- 194
I created an html page contains the following form:
<form action="insert.php" method="post">
<input name="fullname">
<input name="email_address">
<input type="submit" value="submit">
<input type="reset" value="Clear">
</form>
the insert php:
<?php
$connection = mysql_connect ("192.168.0.2:3306", "root", "mypassword"
$db="test_database";
// here we check what errors if any are given
$err_no=mysql_errno();
if ($err_no > 0 ){
// if errors show them
echo mysql_errno() . ": " . mysql_error() . "\n";
}
// here we select which database to use
@mysql_select_db($db,$connection) ;
$err_no=mysql_errno();
if ($err_no > 0 ){
echo " Error: " . mysql_errno() . ": " . mysql_error() . "<br>";
exit;
}
// this is your query to be called
$query = "insert into email_info values ('$fullname', '$email')";
// connect to the db and run the insert
$insert=mysql_query($query, $connection) ;
// here we check what errors if any are given
$err_no=mysql_errno();
if ($err_no > 0 ){
// if errors show them
echo mysql_errno() . ": " . mysql_error() . "\n";
}
//show number of rows affected on successful query
printf ("Records inserted: %d\n", mysql_affected_rows());
?>
I get the following message: Records inserted: 1
But the records was blank, and not as I entered in the form.
I replaced
$query = "insert into email_info values ('$fullname', '$email')";
With:
$sql="INSERT into email_info (fullname,email_address) values ('$fullname', '$email')";
And
$insert=mysql_query($query, $connection) ;
With
$insert=mysql_query($sql, $connection) ;
But I get the same result!! what is wrong here???
Thanks in advance.
<form action="insert.php" method="post">
<input name="fullname">
<input name="email_address">
<input type="submit" value="submit">
<input type="reset" value="Clear">
</form>
the insert php:
<?php
$connection = mysql_connect ("192.168.0.2:3306", "root", "mypassword"
$db="test_database";
// here we check what errors if any are given
$err_no=mysql_errno();
if ($err_no > 0 ){
// if errors show them
echo mysql_errno() . ": " . mysql_error() . "\n";
}
// here we select which database to use
@mysql_select_db($db,$connection) ;
$err_no=mysql_errno();
if ($err_no > 0 ){
echo " Error: " . mysql_errno() . ": " . mysql_error() . "<br>";
exit;
}
// this is your query to be called
$query = "insert into email_info values ('$fullname', '$email')";
// connect to the db and run the insert
$insert=mysql_query($query, $connection) ;
// here we check what errors if any are given
$err_no=mysql_errno();
if ($err_no > 0 ){
// if errors show them
echo mysql_errno() . ": " . mysql_error() . "\n";
}
//show number of rows affected on successful query
printf ("Records inserted: %d\n", mysql_affected_rows());
?>
I get the following message: Records inserted: 1
But the records was blank, and not as I entered in the form.
I replaced
$query = "insert into email_info values ('$fullname', '$email')";
With:
$sql="INSERT into email_info (fullname,email_address) values ('$fullname', '$email')";
And
$insert=mysql_query($query, $connection) ;
With
$insert=mysql_query($sql, $connection) ;
But I get the same result!! what is wrong here???
Thanks in advance.