Forum Moderators: coopster
<?
$username="myusername";
$password="mypassword";
$database="my_db_name";
$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to connect to select database");
$query = "INSERT INTO contacts VALUES (",'$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);
mysql_close();
?>
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/guvna2004/domains/example.co.uk/public_html/test/insert.php on line 18
[edited by: jatar_k at 9:04 pm (utc) on May 3, 2005]
[edit reason] generalized url [/edit]
$dbi = mysql_connect(localhost,$username,$password);
mysql_select_db($database, $dbi) or die("Unable to connect to select database");
$query = "INSERT INTO contacts VALUES (",'$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query, $dbi);
[example.co.uk...]
Fill in some fake info and try it
[edited by: jatar_k at 8:59 pm (utc) on May 3, 2005]
[edit reason] generalized url [/edit]
As long as those variables have the same name as the form input fields:
$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];
you can skip these lines. PHP-script knows the names of all input fields from the html page you do POST from. And variables $first, $last etc will be accesible automatically.