hey guys.
i'm new to php and have a problem inserting data into a mysql table from a form. its connecting ok and comes up data inserted successfully and a new row gets created but the data is blank. any help would be appreciated. thanx. my code is below
HTML
PHP
$connection=mysql_connect("localhost","pp","mm") or die('Could not connect to the database server');
$db = mysql_select_db("test", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO registration (Name,Email)
VALUES ('$name','$email')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>
$connection=mysql_connect("localhost","pp","mm") or die('Could not connect to the database server');
$db = mysql_select_db("test", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO registration (Name,Email)
VALUES ('$name','$email')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>
$connection=mysql_connect("localhost","pp","mm") or die('Could not connect to the database server');
$db = mysql_select_db("test", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO registration (Name,Email)
VALUES ('$name','$email')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>
Hi, ive seen the problem that irishstudent is mentionating...
i took the part of fred and i modifiated a low bit and its giving a blanks record in the database so let show theses codes there:
---------------------------------------------------------------
file name: setuppass.php
---------------------------------------------------------------
include ("config/config.php");
$connection=mysql_connect("$host","$user","$pass") or die('Could not connect to the database server');
$db = mysql_select_db($datab, $connection) or die ("Unable to select database.");
$sql = "INSERT INTO '$tables' (username,passwd)
VALUES ('$username','$passwd')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully');
mysql_close($connection);
?>
$host = "localhost"; //localhost or serveur
$user = "username"; //username
$pass = "password"; //passwd
$datab = ""; //Your Database name
$table = ""; //The table name
?>
--------------------------------------------------------------
And in my MySQL database in the table that i gived to get those records is getting a Blank record... and i passed a little time to look around php site some cue about that... I havec an idea that wrong with multiple insert variables that make some mistake coz ive try to insert only 1 variables and its working mabe with 2 var isnt... why? what i did wrong it that script plz?