Having a little issue with a from and MYSQL.
I created a Job Interview form that takes certain criteria from the interviewer and places that information into a database so you can extract the information later.

What my problem is I'm getting no error messages or successful output. It's not even creating the database in myPHPAdmin in WAMP, and I don't see where I'm going wrong here. Been hashing this over for a few days now.

Here's the code :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Job Interview</title>
<meta http-equiv="content-type"
	content="txt/html; charset=iso-8859-1" />
</head>
<body>
<?php
/* ==== Code to ensure interviewer fills out all required areas === */
if (empty($_GET['first_name']) ||
	empty($_GET['last_name']) ||
	empty($_GET['position']) ||
	empty($_GET['cand_first']) ||
	empty($_GET['cand_last']) ||
	empty($_GET['cand_ID']) ||
	empty($_GET['comments']))
		die("<p>You must enter a value in every field for the interview! Click your 
		browser's Back button to return to the Interview form.</p>");

if (($_GET['month'] == "Month") ||
	($_GET['date'] == "Day") ||
	 ($_GET['year'] == "Year"))
	die ("<p>You must enter the full date in the drop down menus! Click
	     your browser's Back button to return to the Interview form.</p>");
	
if ($_GET['recommendation'] == "--- --- ---")
	die ("<p>You must enter a recommendation value in the drop down menu! Click
	     your browser's Back button to return to the Interview form.</p>");
	
if (($_GET['intellect'] == "--- --- ---") ||
	($_GET['communication'] == "--- --- ---") ||
	($_GET['business'] == "--- --- ---") ||
	($_GET['computer'] == "--- --- ---"))
	die ("<p>You must enter values for all of the Candidate's skills/presentation 
	     from the drop down menues! Click your browser's Back button to return to 
		 the Interview form.</p>");
	
/* ==== Code to connect to the database ==== */
$DBConnect = @mysqli_conntect("localhost", "root", "precision9")
	Or die("<p>Unable to connect to the database server.</p>"
	. "<p>Error code " . mysqli_connect_errno()
	. ": " . mysqli_connect_error()) . "</p>";
	
/* ==== Code to create hit_counter database if it does not already exist ==== */
$DBName = "jobinterview";
if (!@mysqli_select_db($DBConnect, $DBname)) {
	$SQLstring = "CREATE DATABASE $DBName";
	$QueryResult = @mysqli_query($DBConnect, $SQLstring)
		Or die("<p>Unable to execute the query.</p>"
		. "<p>Error code " . mysqli_errno($DBConnect)
		. ": " . mysqli_error($DBConnect)) . "</p>";
	echo "<p>This is the first Candidate</p>";
	echo "<p>Successfully created the database</p>";
	mysqli_select_db($DBConnect, $DBName);
}

/* ==== Code to create a table to give countID === */
$TableName = "candidates";
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring);
if (!$QueryResult) {
		$SQLstring = "CREATE TABLE $TableName (countID SMALLINT
		NOT NULL AUTO_INCREMENT PRIMARY KEY,
		cand_last VARCHAR(40), cand_first VARCHAR(40))";
		$QueryResult = @mysqli_query($DBConnect, $SQLstring)
		Or die("<p>Unable to create the table.</p>"
		. "<p>Error code " . mysqli_errno($DBConnect)
		. ": " . mysqli_error($DBConnect)) . "</p>";
	echo "<p>Successfully created the candidates table</p>";
}

/* ==== Adds the candidate to the database and closes the connection ==== */
$LastName = addslashes($_GET['cand_last']);
$FirstName = addslashes($_GET['cand_first']);
$SQLstring = "INSERT INTO $TableName VALUES(NULL, '$LastName',
	'$FirstName')";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
	Or die("<p>Unable to execute the query.</p>"
		. "<p>Error code " . mysqli_errno($DBConnect)
		. ": " . mysqli_error($DBConnect)) . "</p>";
echo "<strong>Interview Saved</strong>";
mysqli_close($DBConnect);
?>
</body>
</html>

Any help is much appreciated.

Welp, that was honestly stupid. It was a simple syntax problem in my $DBConnect code that I couldn't see in my editor but could on here with the different color text quite easily.

I'm currently using Notepad++ as an editor. Anyone have any suggestion on an editor of choice?

I do have a problem though that's been plaguing a few of my MYSQL programs.

Here is my error code:

Unable to execute the query.

Error code 1007: Can't create database 'jobinterview'; database exists

Now, This happens only after I save the first interview. Everything works fine for the first interview. As soon as I go to put in the second one for testing this happens and has happened to another program I was working on which I was never able to fix.

Here's the code again: "Working" this time.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Job Interview</title>
<meta http-equiv="content-type"
	content="txt/html; charset=iso-8859-1" />
</head>
<body>
<?php
/* ==== Code to ensure interviewer fills out all required areas === */
if (empty($_GET['first_name']) ||
	empty($_GET['last_name']) ||
	empty($_GET['position']) ||
	empty($_GET['cand_first']) ||
	empty($_GET['cand_last']) ||
	empty($_GET['cand_ID']) ||
	empty($_GET['comments']))
		die("<p>You must enter a value in every field for the interview! Click your 
		browser's Back button to return to the Interview form.</p>");

if (($_GET['month'] == "Month") ||
	($_GET['date'] == "Day") ||
	 ($_GET['year'] == "Year"))
	die ("<p>You must enter the full date in the drop down menus! Click
	     your browser's Back button to return to the Interview form.</p>");
	
if ($_GET['recommendation'] == "--- --- ---")
	die ("<p>You must enter a recommendation value in the drop down menu! Click
	     your browser's Back button to return to the Interview form.</p>");
	
if (($_GET['intellect'] == "--- --- ---") ||
	($_GET['communication'] == "--- --- ---") ||
	($_GET['business'] == "--- --- ---") ||
	($_GET['computer'] == "--- --- ---"))
	die ("<p>You must enter values for all of the Candidate's skills/presentation 
	     from the drop down menues! Click your browser's Back button to return to 
		 the Interview form.</p>");
	
/* ==== Code to connect to the database ==== */
$DBConnect = @mysqli_connect("localhost", "root", "precision9")
	Or die("<p>Unable to connect to the database server.</p>"
	. "<p>Error code " . mysqli_connect_errno()
	. ": " . mysqli_connect_error()) . "</p>";
	
/* ==== Code to create hit_counter database if it does not already exist ==== */
$DBName = "jobinterview";
if (!@mysqli_select_db($DBConnect, $DBname)) {
	$SQLstring = "CREATE DATABASE $DBName";
	$QueryResult = @mysqli_query($DBConnect, $SQLstring)
		Or die("<p>Unable to execute the query.</p>"
		. "<p>Error code " . mysqli_errno($DBConnect)
		. ": " . mysqli_error($DBConnect)) . "</p>";
	echo "<p>This is the first Candidate</p>";
	echo "<p>Successfully created the database</p>";
	mysqli_select_db($DBConnect, $DBName);
}

/* ==== Code to create a table to give countID === */
$TableName = "candidates";
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring);
if (!$QueryResult) {
		$SQLstring = "CREATE TABLE $TableName (countID SMALLINT
		NOT NULL AUTO_INCREMENT PRIMARY KEY,
		cand_last VARCHAR(40), cand_first VARCHAR(40))";
		$QueryResult = @mysqli_query($DBConnect, $SQLstring)
		Or die("<p>Unable to create the table.</p>"
		. "<p>Error code " . mysqli_errno($DBConnect)
		. ": " . mysqli_error($DBConnect)) . "</p>";
	echo "<p>Successfully created the candidates table</p>";
}

/* ==== Adds the candidate to the database and closes the connection ==== */
$LastName = addslashes($_GET['cand_last']);
$FirstName = addslashes($_GET['cand_first']);
$SQLstring = "INSERT INTO $TableName VALUES(NULL, '$LastName',
	'$FirstName')";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
	Or die("<p>Unable to execute the query.</p>"
		. "<p>Error code " . mysqli_errno($DBConnect)
		. ": " . mysqli_error($DBConnect)) . "</p>";
echo "<strong>Interview Saved</strong>";
mysqli_close($DBConnect);
?>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.