Hi I am a newbie with mysql and php, and I am having trouble creating a table and inserting values into the table. I have a database which I created already and I have connected to. I don't get any error messages when I try connecting to it. The following code is in my main file and I am not receiving any errors with it but when I check phpMyAdmin to view if the table has been created, I see nothing in my database.
Code:
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn) || die ("Error selecting database");
$query = 'CREATE TABLE registration( '.
'name CHAR(50), '.
'number CHAR(20), '.
'title CHAR(50), '.
'language CHAR(30))';
$result = mysql_query($query) || die('Couldn't create table');
Also on another php page I am processing information from a form and trying to insert it into the above created table but I keep getting an error in inserting the query.
Code:
$query = "INSERT INTO registration values ('".$_POST['name']."','".$_POST['songnum']."','".$_POST['songtitle']."','".$_POST['language']."');";
mysql_query($query) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');
Any help would be appreciated. Thanks