0

hello there, i'm having a bit of trouble about this.
im making a regiter page for our project and im using PHP, and im having a little problem,

it says that: Could not execute the insert query.. but i got all my fields right?..

<?php 
	include("config.php");
	if(isset($_POST['submit']))
	{
		$fname = $_POST['fname'];
		$lname = $_POST['lname'];
		$email = $_POST['email'];
		$user = $_POST['uname'];
		$pass = $_POST['pass'];	
		$mos = $_POST['Month'];
		$date = $_POST['day'];
		$yr = $_POST['year'];
		
		
		if($user =="" || $pass=="")
		{
			echo "Either username or password field is empty.";
			echo "<br/>";
			echo "<a href='register.php'>Go back</a>";	
		}
		else
		{
			mysql_query("INSERT INTO login (id,uname,pass,fname,lname,email,bmonth,bday,byear)) 
				values ('$user','$pass',$fname,$lname,$email,$mos,$date,$yr)",$conn)
				
			or die("Could not execute the insert query");

----
im using combo box for my month,date and year..that is for the birthdate

please help.. thanks in advance

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by diafol
1

Some of the fields need to have quotes around them, e.g. '$fname','$lname','$email', possibly '$date'.

Also make sure you escape all variables with mysql_real_escape_string or check that they are integers with is_int() and that they fall within the expected range.

0

thank you.. :)
im still new to php that's y i overlooked some of the quotes... thanks again.. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.