otuatail Posted July 31, 2007 Share Posted July 31, 2007 I have heard of this type of problem before. I am copying some data from one table to another but one of the values of a text field has a space in it. $name = "Paul"; $address = "My House"; $sql = "Insert into Newtable (name , address) VALUSE ($name , $address )"; Result ERROR near House This is going to cuse a big problem with spaces in strings. I believe there is a solution to this. Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/62628-solved-insert-values/ Share on other sites More sharing options...
hostfreak Posted July 31, 2007 Share Posted July 31, 2007 I don't think the space should be causing any problems: $name = "Paul"; $address = "My House"; $sql = "INSERT INTO Newtable(name , address) VALUES('$name','$address')"; You do have "VALUES" spelled right in the actual script, right? Quote Link to comment https://forums.phpfreaks.com/topic/62628-solved-insert-values/#findComment-311727 Share on other sites More sharing options...
otuatail Posted July 31, 2007 Author Share Posted July 31, 2007 There are no single quotes in the query INSERT INTO Accounts( f_name, l_name, friendly, address, PC, email, user, pwd, GUID, pwd2, Validate ) VALUES ( Michael, Jackson, Mickey, My Home, YO30 6BT, michael.jackson@neverland - park.com, Neverland, Thriller, 1184422857, 41ce88c91e341fce1c4d961ef9244c32, Y ) Quote Link to comment https://forums.phpfreaks.com/topic/62628-solved-insert-values/#findComment-311729 Share on other sites More sharing options...
hostfreak Posted July 31, 2007 Share Posted July 31, 2007 Have you tried what I suggested? Using single quotes will allow it to parse white spaces. Quote Link to comment https://forums.phpfreaks.com/topic/62628-solved-insert-values/#findComment-311732 Share on other sites More sharing options...
otuatail Posted July 31, 2007 Author Share Posted July 31, 2007 This is the SQL $sql_out = "INSERT INTO Accounts (f_name , l_name , friendly , address , PC , email , user , pwd , GUID , pwd2 , Validate) "; $sql_out .= " VALUES ($f_name , $l_name , $friendly , $address , $PC , $email , $user , $pwd , $GUID , $md5 , $Validate)"; Do I have to put single quotes around every value as in VALUES ( " ' " . $f_name . " ' , '" Quote Link to comment https://forums.phpfreaks.com/topic/62628-solved-insert-values/#findComment-311736 Share on other sites More sharing options...
hostfreak Posted July 31, 2007 Share Posted July 31, 2007 $sql_out = "INSERT INTO Accounts (f_name , l_name , friendly , address , PC , email , user , pwd , GUID , pwd2 , Validate) "; $sql_out .= " VALUES ($f_name , $l_name , $friendly , '$address' , $PC , $email , $user , $pwd , $GUID , $md5 , $Validate)"; Quote Link to comment https://forums.phpfreaks.com/topic/62628-solved-insert-values/#findComment-311737 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.