[SOLVED]unexpected T_ENCAPSED_AND_WHITESPACE

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

[SOLVED]unexpected T_ENCAPSED_AND_WHITESPACE

Post by Straterra »

I am getting the following error : Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\ftp\users\straterra\eck\cgi-bin\full1.php on line 53

Now, this is line 53 :

Code: Select all

sqlite_query($db, "insert into clanprofile2 (firstname, lastname, middleinit, birthyear, socomname, socommap, sealswep, terrwep, website, hometown, picture, gender, birthday, occupation, bands, tvshows, movies, bgcolor, textcolor, picorcolor, music) values ($result['firstname'], $result['middleinit'], $result['lastname'], $result['birthyear'], '$user', $result['socommap'], $result['sealswep'], $result['terrwep'], $result['website'], $result['hometown'], $result['picture'], $result['birthday'], $result['gender'], $result['occupation'], $result['bands'], $result['tvshows'], $result['movies'], 'white', 'black', 'color', 'none')");
Last edited by Straterra on Sat Jan 10, 2004 3:31 pm, edited 1 time in total.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

You need to quote all of those strings.

'$result['birthyear']' ... etc.
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

I did that..same error.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

What does it look like now?
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Code: Select all

sqlite_query($db, "insert into clanprofile2 (firstname, lastname, middleinit, birthyear, socomname, socommap, sealswep, terrwep, website, hometown, picture, gender, birthday, occupation, bands, tvshows, movies, bgcolor, textcolor, picorcolor, music) values ('$result['firstname']', '$result['middleinit']', '$result['lastname']', '$result['birthyear']', '$user', '$result['socommap']', '$result['sealswep']', '$result['terrwep']', '$result['website']', '$result['hometown']', '$result['picture']', '$result['birthday']', '$result['gender']', '$result['occupation']', '$result['bands']', '$result['tvshows']', '$result['movies']', 'white', 'black', 'color', 'none')");
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Yeah, those inner single quotes are gonna cause some major problems...

Two things you can do:

Bad, but easy way:

sqlite_query($db, "insert into clanprofile2 (firstname, lastname, middleinit, birthyear, socomname, socommap, sealswep, terrwep, website, hometown, picture, gender, birthday, occupation, bands, tvshows, movies, bgcolor, textcolor, picorcolor, music) values ('$result[firstname]', '$result[middleinit]', '$result[lastname]', '$result[birthyear]', '$user', '$result[socommap]', '$result[sealswep]', '$result[terrwep]', '$result[website]', '$result[hometown]', '$result[picture]', '$result['birthday]', '$result[gender]', '$result[occupation]', '$result[bands]', '$result[tvshows]', '$result[movies]', 'white', 'black', 'color', 'none')");

I think I got them all.

Good, but longer way:

Concatenate strings to create the query.

Like you'd go

" .. stuf stuf stuff, ".$result['firstname'].", ".$result['lastname']." stuf stuf stuf";
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

The bad, easy way doesn't work. What I am going to do is assign each of those into variables, and it should be MUCH easer, don't ya think?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Straterra wrote:The bad, easy way doesn't work. What I am going to do is assign each of those into variables, and it should be MUCH easer, don't ya think?
Yeah.
Post Reply