Jump to content

Error


LiamProductions
 Share

Recommended Posts

Hey...

Im getting a error on my script code:

 

<?php

if(!isset($_POST['submitReg'])) { 
if(!isset($_POST['username'])) {
	echo "Please enter a username";
}
else {
	if(!isset($_POST['pass'])) {
		echo "Please enter a password";
	}
	else {
		if(!isset($_POST['passConf'])) {
			echo "Please enter a confirm password";
			}
	else {
		if(!isset($_POST['email'])) {
			echo "Please enter a email address";
		}
	else {
		$user = $_POST['username'];
                        $user = strip_tags($user);
		$pass = $_POST['pass'];
		$passConf = $_POST['passConf'];
		$email = $_POST['email'];
                        $email = strip_tags($email);
		if(strlen($user) < 4 || strlen($user) > 15) {
			echo "You entered a too long or short username";
		}
		elseif(strlen($pass) < 6 || strlen($pass) > 50) {
			echo "You entered a too long or short username";
		}
		elseif(strlen($email) < 5 || strlen($pass) > 60) {
			echo "You entered a too long or short username";
		}
		else {
			if(!isset($_POST['sport'])) {
				echo "Please enter a favourite sport";
			}
                                elseif ($pass != $passConf) {
                            echo "Password did not match";
                                  }
			else {
				$sport = $_POST['sport'];

				if($sport != 'Football' && $sport != 'Basketball' && $sport != 'Tennis' && $sport != 'Hockey' && 
				$sport != 'Rugby' && $sport != 'Bike Riding' && $sport != 'Swimming') {
					echo "Please pick a favourite sport";
				}
                                    else {
                                          $IP = $_SERVER['REMOTE_ADDR'];
                                          $date = date('d/m/y');

                                       $connection = mysql_connect('localhost', 'liam_liam', 'code090');

                                      $storedata = mysql_query('INSERT INTO liam_database(Username, Password, Email,Favourite Sport,IP,date);  
                                      VALUES ( "'.addslashes($user).'"   
                                               "'.md5($pass).'"
                                               "'.addslashes($email).'"
                                               "'.addslashes($sport).'"
                                               "'.addslashes($IP).'"
                                               "'.addslashes($date).'" ') or die(mysql_error());
                                      echo "Successfully Registered!";               

                                       mysql_close($connection);
			}
		}
		}
		}	
	}
	}
}
}
else {
	echo "Please enter the fields!";
}
?>

 

The error is: 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 'Sport, IP, date); VALUES ( "liam" ' at line 1

Link to comment
Share on other sites

Finding errors will be enormously simplified if you use a code arrangement like this:

 

define the querystring

execute the query with sensible error trapping

 

$query = "INSERT into ..... whatever it is ....."; // define querystring
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // show error details

Link to comment
Share on other sites

Sorry to miss all the others...

$storedata = mysql_query('INSERT INTO liam_database(Username, Password, Email,Favourite Sport,IP,date);  
                                     VALUES ( "'.addslashes($user).'",   
                                              "'.md5($pass).'",
                                              "'.addslashes($email).'",
                                              "'.addslashes($sport).'",
                                              "'.addslashes($IP).'",
                                              "'.addslashes($date).'")') or die(mysql_error());

Missing , in values set and ) at the end.

Link to comment
Share on other sites

You need to take more responsibilty for your own errors, not keep dumping them on us.  How long did you look for the problem?  Why didn't you implement error trapping as I recommended two posts ago - then you could have seen the entire querystring that was causing the error.

 

Take a deep breath. Check your code. Check it again. Add error-trapping. Test it. And if you really can't see the problem, then post again in ten minutes, not ten seconds.

Link to comment
Share on other sites

You need to take more responsibilty for your own errors, not keep dumping them on us.  How long did you look for the problem?  Why didn't you implement error trapping as I recommended two posts ago - then you could have seen the entire querystring that was causing the error.

 

Take a deep breath. Check your code. Check it again. Add error-trapping. Test it. And if you really can't see the problem, then post again in ten minutes, not ten seconds.

 

I've just tried to do the error finding and i fixed some things well i think so now this is something im getting:

Error: Query was empty with query

from:

 

$query = mysql_query("INSERT into liam_database(Username, Password, Email,fsport,IP,date"); // define querystring

$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // show error details

 

does that mean its working now?

Link to comment
Share on other sites

This query....

 

$query = mysql_query("INSERT into liam_database(Username, Password, Email,fsport,IP,date");

 

Is missing the VALUES. Also note that Passowrd and date are reserved words on mysql. Seems you need to find some tutorials. Theres a great link in my signiture.

 

As for your parse error. We'd need to see some code.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.