I've looked up many different answers to the question I'm asking but none have them have seemed to work and im completely confused as to why. Here the the problem: When ever I enter the information into the form on the website, I get the message Error: No database Selected. here is the code:
<?php
//move the connect to database and select database to the header place.
$dbhost = 'SNIPPED';
$dbuser = 'SNIPPED';
$dbpass = 'SNIPPED';
$mydb = 'SNIPPED';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully! yay! ';
mysql_select_db($mydb, $conn) or die('OH BOO ERROER' . mysql_error() );
$SQL = " CREATE TABLE k (";
$SQL = $SQL . " id INT NOT NULL AUTO_INCREMENT, ";
$SQL = $SQL . " FirstName VARCHAR(50), ";
$SQL = $SQL . " JobTitle VARCHAR(75), ";
$SQL = $SQL . " Email VARCHAR(40), ";
$SQL = $SQL . " PhoneNum VARCHAR(10), ";
$SQL = $SQL . " category VARCHAR(50), ";
$SQL = $SQL . " PRIMARY KEY(id) );";
$shala = mysql_db_query($kylansdb,"$SQL",$conn);
if (!$shala)
{
die('Error: ' . mysql_error());
}
$sql="INSERT INTO k (FirstName, JobTitle, Email, PhoneNum)
VALUES
('$_POST[FirstName]','$_POST[JobTitle]','$_POST[Email]','$_POST[PhoneNum]')";
echo "1 record added";
mysql_close($conn);
?>
If you have any ideas I'm wide open to them. Also, if there are any earrors in the code that may be making the "Error: No database selected" thing happen, I would be happy to learn of them.