I am trying to transfer $_SESSION variables into MySQL. However there is an error in my MySQL statements.
This is the error that I receive:
Unable to execute the query.
Error code 1136: Column count doesn't match value count at row 1
Could somebody let me know what exactly is wrong?
Code: <?php
session_start();
if (empty($_SESSION['FirstName']) ||
empty($_SESSION['LastName']) ||
empty($_SESSION['HomeAddress']) ||
empty($_SESSION['HomeCity']) ||
empty($_SESSION['HomeState']) ||
empty($_SESSION['HomeZip']) ||
empty($_SESSION['HomePhone']) ||
empty($_SESSION['HomeEmail'])||
empty($_SESSION['company'])||
empty($_SESSION['caddress'])||
empty($_SESSION['ccity'])||
empty($_SESSION['czip'])||
empty($_SESSION['cphone'])||
(
!isset($_SESSION['HTML5_camp'])&&
!isset($_SESSION['phyton_camp'])&&
!isset($_SESSION['perl_camp'])&&
!isset($_SESSION['glassfish_camp'])
))
header("location:AtendeeReview.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Conference</title>
</head>
<body>
<h1>Conference Registration</h1>
<?php
$DBConnect = @mysqli_connect("localhost", "root", "")//MYSQl connection
Or die("<p>Unable to connect to the database server.</p>"
. "<p>Error code " . mysqli_connect_errno()
. ": " . mysqli_connect_error()) . "</p>";
$DBName = "conference"; //create database
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>Successfully created the database.</p>";
mysqli_select_db($DBConnect, $DBName);
}
$TableName = "attendees";//create table
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring);
if (!$QueryResult) {
$SQLstring = "CREATE TABLE $TableName (attendeeID SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY, firstName VARCHAR(40), lastName VARCHAR(40), homeaddress VARCHAR(40), homecity VARCHAR(40), homestate VARCHAR(2), homezip VARCHAR(10), homephone VARCHAR(40), homeemail VARCHAR(40), comapny VARCHAR(50), companyaddress VARCHAR(40), companystate VARCHAR(2), comapnyzip VARCHAR (10), companyphone VARCHAR(40), trainingsessions VARCHAR(40))";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to create the $TableName table.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
echo "<p>Successfully created the $TableName table.</p>";
}
$SQLstring = "SELECT * FROM $TableName WHERE firstName='{$_SESSION['FirstName']}' && lastName='{$_SESSION['LastName']}'";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to execute the query igor.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
$NumRows = mysqli_num_rows($QueryResult);
if ($NumRows > 0)
exit("<p>Your name is already registered for the conference!</p>
<form action='PersonalInfo.php' method='post'>
<p><input type='submit' value='Back' /></p>
</form>");
$FirstName = addslashes($_SESSION['FirstName']);
$LastName = addslashes($_SESSION['LastName']);
$HAddress = addslashes($_SESSION['HomeAddress']);
$HCity = addslashes($_SESSION['HomeCity']);
$HState = addslashes($_SESSION['HomeState']);
$HZip = addslashes($_SESSION['HomeZip']);
$HPhone = addslashes($_SESSION['HomePhone']);
$HEmail = addslashes($_SESSION['HomeEmail']);
$Company = addslashes($_SESSION['company']);
$CAddress = addslashes($_SESSION['caddress']);
$CCity = addslashes($_SESSION['ccity']);
$CState = addslashes($_SESSION['cstate']);
$CZip = addslashes($_SESSION['czip']);
$CPhone = addslashes($_SESSION['cphone']);
$CEmail = addslashes($_SESSION['cemail']);
$HTML5Conf = addslashes($_SESSION['HTML5_camp']);
$PhytonConf = addslashes($_SESSION['phyton_camp']);
$RubyConf = addslashes($_SESSION['ruby_camp']);
$PerlConf = addslashes($_SESSION['perl_camp']);
$GlassFishConf = addslashes($_SESSION['glassfish_camp']);
$SQLstring = "INSERT INTO $TableName VALUES(NULL, '$FirstName', '$LastName', '$HAddress', '$HCity', '$HState', '$HZip', '$HPhone', '$HEmail', '$Company', '$CAddress', '$CCity', '$CState', '$CZip', '$CPhone', '$CEmail', '$HTML5Conf', '$PhytonConf', '$RubyConf', '$GlassFishConf')";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to execute the query.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
mysqli_close($DBConnect);
session_destroy();
?>
New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understand simple arrays, associative arrays, and multidimensional arrays also. The book I am reading
Code error with Index.php
Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/runevid/public_html/index.php on line 25<html><head><title>CrazyQuest -
Not showing whole name with mail () script
I sent up a simple mail form with the PHP mail() script. One problem is when it sends an email with the form's contents, the From header only reads the first name and shows @domain.com in the From
double and single quotes in text fields acting up... help please
Single quotes, when entered into a text field, create an sql error upon Submit. It seems to create the query OK but says there's an SQL syntax error and stalls out on that field.Also any time a
Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out where the best place to start would be.Website PagesBackstage 2 provides website pages for the
PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending upon where the visitor comes from. The code below works but looses the original referrer information
Array becomes unset by itself?
Hi,I have a bit of experience with PHP but not extensive. It seems I cannot store any items to the array $details. The class:class Newsletter {public $details = array();function Newsletter($id)
PHP hyperlinks generator
HiI need some help to get this done using php:1 - I have few hyperlinks say 500 in format like:<a href="http://domaina.com/1.html"
PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Here's the xml i want to extract:http://dblp.uni-trier.de/search/author?xauthor=SchekWhat I
Google Wave
So... has anyone used it yet? Is it any good?http://wave.google.com/help/wave/about.html#video