Thanks elipollak. Although your code did what it was supposed to do, I still get no data entered into MySQL database. Curoius...do you think I may have too many characters in $query = "INSERT INTO 'requests' once the variables are sent?
I noticed that in creating the tables I wasn't able to use a single line to create all the columns. I had to partially create the table then use the ALTER TABLE command to finnish it off. Could this be in some way related? Would it make sense for me to break up the $query operation? ( if it is a opreation...I'm a n00b)
Another n00b messing it up
Moderator: General Moderators
- gyardleydn
- Forum Commoner
- Posts: 27
- Joined: Tue Dec 03, 2002 8:27 am
Code: Select all
<?php
$query = "INSERT INTO 'requests' 'INSERT INTO `requests` ( `first` , `last` , `title` ,
`salon_name` , `address1` , `address2` , `city` , `state` , `Zip` , `phone` , `email` ,
`requested_cat` , `comments` , `date` ) VALUES ('$FirstName', '$LastName', '$Title',
'$SalonName','$Address1', '$Address2', '$City', '$State', '$Zip', '$Phone',
'$Email','$YesNo', '$Date', '$Comments')";- gyardleydn
- Forum Commoner
- Posts: 27
- Joined: Tue Dec 03, 2002 8:27 am
Code: Select all
echo (mysql_affected_rows()?"success":"failure");Code: Select all
echo (mysql_affected_rows() > 0?"success":"failure"), '<BR>';OMFG! Heres your problem
INSERT INTO 'requests' 'INSERT INTO `requests
----------------------------
You doubled a SQL statement.
Try this:
<?php
$query = "INSERT INTO requests (";
$query .= "'first','last','title','salon_name','address1','address2','city','state','Zip','phone','email','requested_cat','comments','date' ) VALUES (";
$query .= "'$FirstName', '$LastName', '$Title', '$SalonName','$Address1', '$Address2', '$City', '$State', '$Zip', '$Phone', '$Email','$YesNo', '$Comments','$Date' );
if ( mysql_query( $query ) )
{
echo "Entry Success";
}
else
{
echo "Failed!";
}
?>
OK your other problem was you were defining the variables to the VALUES wrong. You HAVE to put the VALUES in as they are in the INSERT SQL Statement.
Hope this works
INSERT INTO 'requests' 'INSERT INTO `requests
----------------------------
You doubled a SQL statement.
Try this:
<?php
$query = "INSERT INTO requests (";
$query .= "'first','last','title','salon_name','address1','address2','city','state','Zip','phone','email','requested_cat','comments','date' ) VALUES (";
$query .= "'$FirstName', '$LastName', '$Title', '$SalonName','$Address1', '$Address2', '$City', '$State', '$Zip', '$Phone', '$Email','$YesNo', '$Comments','$Date' );
if ( mysql_query( $query ) )
{
echo "Entry Success";
}
else
{
echo "Failed!";
}
?>
OK your other problem was you were defining the variables to the VALUES wrong. You HAVE to put the VALUES in as they are in the INSERT SQL Statement.
Hope this works