obaluba
02-01-2007, 11:15 AM
Another simple one (I hope)
I'm still learning PHP, I've managed to view the records in my mysql db but i cant seem to add a record, ive made a basic html form, which all checks out, along with this php file:
<?
$dbhost='localhost';
$user='cdesi_admin';
$password='abcd';
$database='cdesi_contacts';
/* $dbh=mysql_connect ("localhost", "cdesi_admin", "abcd") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cdesi_contacts");
*/
$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobille=$_POST['mobille'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];
mysql_connect($dbhost,$user,$password);
@mysql_select_db($database) or die("Unable to Select Database");
mysql_query($query);
/* $query = "INSERT INTO cdesi_contacts VALUES ('first', 'last', 'phone', 'mobille', 'fax', 'email', 'web')"; */
$query = "INSERT INTO `contacts` VALUES ( `id` , `first` , `last` , `phone` , `mobille` , `fax` , `email` , `web` )";
mysql_close();
?>
when I run this, it just gives me a blank page with no errors, however the database doesnt update? I'm not sure what I'm doing wrong.
The database is called contacts as is the table and ive got a user login which gives me full access
any help would be really appreciated!
thanks :)
I'm still learning PHP, I've managed to view the records in my mysql db but i cant seem to add a record, ive made a basic html form, which all checks out, along with this php file:
<?
$dbhost='localhost';
$user='cdesi_admin';
$password='abcd';
$database='cdesi_contacts';
/* $dbh=mysql_connect ("localhost", "cdesi_admin", "abcd") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cdesi_contacts");
*/
$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobille=$_POST['mobille'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];
mysql_connect($dbhost,$user,$password);
@mysql_select_db($database) or die("Unable to Select Database");
mysql_query($query);
/* $query = "INSERT INTO cdesi_contacts VALUES ('first', 'last', 'phone', 'mobille', 'fax', 'email', 'web')"; */
$query = "INSERT INTO `contacts` VALUES ( `id` , `first` , `last` , `phone` , `mobille` , `fax` , `email` , `web` )";
mysql_close();
?>
when I run this, it just gives me a blank page with no errors, however the database doesnt update? I'm not sure what I'm doing wrong.
The database is called contacts as is the table and ive got a user login which gives me full access
any help would be really appreciated!
thanks :)