Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP error on page submit
#1
Hi, i am trying to create a registration page for my website, however when i test it and click the submit button i get this error,

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2"

I have tried everything to try and fix this but cannot do it.

Anyone have any ideas,

Heres my code

PHP Code:
<?php
// Code only runs if submit button is pressed
if (isset ($_POST['firstname'])){
     
$firstname $_POST['firstname'];
  
$lastname $_POST['lastname'];
     
$username $_POST['username'];
  
$email $_POST['email'];
  
$password $_POST['password'];
  
$cpassword $_POST['cpassword'];
  
$paypal_email $_POST['paypal_email'];
  
$country $_POST['country'];
     
$kingdom_name $_POST['kingdom_name'];
  
$kingdom_motto $_POST['kingdom_motto'];
     
$referal $_POST['referal'];
  
$newsletter $_POST['newsletter'];

  include_once 
"connect_to_mysql.php";
  
$emailCHecker mysql_real_escape_string($email);
     
$emailCHecker eregi_replace("`"""$emailCHecker);
     
$usernameCHecker mysql_real_escape_string($username);
     
$usernameCHecker eregi_replace("`"""$usernameCHecker);
  
// Database duplicate e-mail check setup for use below in the error handling if else conditionals
  
$sql_email_check mysql_query("SELECT email FROM user_info WHERE email='$emailCHecker'");
  
$email_check mysql_num_rows($sql_email_check); 
     
$sql_username_check mysql_query("SELECT username FROM user_info WHERE username='$usernameCHecker'");
  
$username_check mysql_num_rows($sql_username_check); 

  
// Error handling for missing data
  
if ((!$firstname) || (!$lastname) || (!$username) || (!$email) || (!$password) || (!$cpassword) || (!$paypal_email) || (!$kingdom_name) || (!$kingdom_motto)) { 

  
$errorMsg 'ERROR: You did not submit the following required information:<br /><br />';

  if(!
$firstname){ 
  
$errorMsg .= ' * Firstname<br />';
  } 
     if(!
$lastname){ 
  
$errorMsg .= ' * Lastname<br />';
  } 
     if(!
$username){ 
  
$errorMsg .= ' *Username<br />';
  } 
  if(!
$email){ 
  
$errorMsg .= ' * Email<br />';
  }     
     if(!
$password){ 
  
$errorMsg .= ' * Password<br />';  
  }
     if(!
$cpassword){ 
  
$errorMsg .= ' * Confirmation Password<br />';  
  } 
     if(!
$paypal_email){ 
  
$errorMsg .= ' * Paypal Email<br />';  
  } 
     if(!
$kingdom_name){ 
  
$errorMsg .= ' * Kingdom Name<br />';  
  }
     if(!
$kingdom_motto){ 
  
$errorMsg .= ' * Kingdom Password<br />';  
  }            

  } else if (
$password != $cpassword) {
    
$errorMsg 'ERROR: Your Password fields below do not match<br />';         
  } else if (
$email_check 0){ 
    
$errorMsg "<u>ERROR:</u><br />Your Email address is already in use inside our database. Please use another.<br />";
     } else if (
$username_check 0){ 
    
$errorMsg "<u>ERROR:</u><br />Username selected is already in use. Please choose another.<br />"

  } else { 
// Error handling is ended

  // Add MD5 Hash to the password
  
$password md5($password); 

  
// Add user info into the database table
  
$sql mysql_query("INSERT INTO user_info (firstname, lastname, username, email, password, sign_up_date) 
  VALUES('
$firstname','$lastname','$username','$email','$password', now()")  
  or die (
mysql_error());

  
$id mysql_insert_id();

  
mkdir("members/$id"0755);    

   include_once 
'msgToUser.php'

   exit();

   } 
// Close else

} else { // if the form is not posted with variables, place default empty variables so no warnings or errors show

      
$errorMsg "";
      
$firstname "";
  
$lastname "";
      
$username "";
      
$email "";
      
$password "";
      
$cpassword "";
      
$paypal_email "";
      
$kingdom_name "";
      
$kingdom_motto "";
      
$referal "";
}

?>
Reply


Messages In This Thread
PHP error on page submit - by kaosjon - 09-17-2011, 03:51 AM
RE: PHP error on page submit - by Fragma - 09-17-2011, 05:20 AM
RE: PHP error on page submit - by AceInfinity - 09-17-2011, 06:14 AM
RE: PHP error on page submit - by Gaijin - 09-17-2011, 05:53 PM
RE: PHP error on page submit - by AceInfinity - 09-17-2011, 06:54 PM
RE: PHP error on page submit - by Gaijin - 09-17-2011, 07:43 PM
RE: PHP error on page submit - by +Awesome - 09-18-2011, 01:47 AM
RE: PHP error on page submit - by AceInfinity - 09-18-2011, 03:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 765 07-27-2020, 11:26 PM
Last Post: tk-hassan
  [PHP] Very Basic Login Page BreShiE 17 6,904 07-11-2013, 05:57 AM
Last Post: 1n9i9c7om ツ
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,253 10-10-2011, 01:00 PM
Last Post: Greyersting
  [TUT] PHP Password Protected Page PurpleHaze 23 5,755 05-20-2011, 02:56 AM
Last Post: stephen5565
  PHP DISABLE HTML ON MEMBERS PAGE Leprechaun Coder 8 2,002 05-14-2011, 09:44 PM
Last Post: Leprechaun Coder

Forum Jump:


Users browsing this thread: 1 Guest(s)