944,179 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2641
  • PHP RSS
Jul 8th, 2007
0

parse error, unexpected T_STRING in

Expand Post »
I'm trying to learn php and I'm trying to build a simple form that stores data. However, I'm getting this error message when I submit my form:

Parse error: parse error, unexpected T_STRING in /sites/yuma2/swaters210/home/public_html/music/music.php on line 7


you check out my form here: http://www.stevenwaters.net/music/index.html


PHP Syntax (Toggle Plain Text)
  1.  
  2.  
  3. <?
  4. $artist=$_POST['artist'];
  5. $song=$_POST['song'];
  6. $album=$_POST['album'];
  7. mysql_connect("localhost", "swaters210", "password") or die(mysql_error());
  8. mysql_select_db("swaters210") or die(mysql_error());
  9. CREATE TABLE data (artist VARCHAR(30), song VARCHAR(30), album VARCHAR(30));
  10. mysql_query("INSERT INTO `data` VALUES ('$artist', '$song', '$album')");
  11. Print "Your information has been successfully added to the database.";
  12. ?>

FYI: I do know I have to replace password with an actual password, which I have.

PHP Syntax (Toggle Plain Text)
  1.  
  2. <form method="POST" action="music.php">
  3. <label for="artist"><b>Artist Name:</b></label>
  4. <input type="text" name="artist" value="" /><br />
  5. <label for="song"><b>Song Title:</b></label>
  6. <input type="text" name="song" value="" /><br />
  7. <label for="album"><b>Album:</b></label>
  8. <input type="text" name="album" value="" /><br />
  9. <input type="submit" name="submitbutton" id="submitbutton" value="Submit" />

Can someone check it out for me? I would appreciate it. I was going to post in a similiar thread, but wasn't sure if anybody would see it.
Reputation Points: 10
Solved Threads: 0
Light Poster
swaters86 is offline Offline
26 posts
since Jul 2007
Jul 8th, 2007
0

Re: parse error, unexpected T_STRING in

What is exactly line 7 within your .php file?
It's just a syntax error, and can be worked out momentarily for you

Cheers.
Reputation Points: 35
Solved Threads: 5
Junior Poster
dr4g is offline Offline
136 posts
since Apr 2007
Jul 8th, 2007
0

Re: parse error, unexpected T_STRING in

What is this ?!?

sql Syntax (Toggle Plain Text)
  1. CREATE TABLE data (artist VARCHAR(30), song VARCHAR(30), album VARCHAR(30));

- Mitko Kostov
Last edited by MitkOK; Jul 8th, 2007 at 9:58 am.
Reputation Points: 59
Solved Threads: 12
Junior Poster
MitkOK is offline Offline
142 posts
since Jul 2007
Jul 8th, 2007
0

Re: parse error, unexpected T_STRING in

yes that's the problem then! lol that code either shouldnt be there! it's not valid PHP, if its a valid mySQL function it will need wrapped in a mysql_query() statement

Welldone Mitko for spotting it
Reputation Points: 35
Solved Threads: 5
Junior Poster
dr4g is offline Offline
136 posts
since Apr 2007
Jul 8th, 2007
0

Re: parse error, unexpected T_STRING in

How do you wrap it in a mysql_query() statement? I was just following this tutorial here:

http://php.about.com/od/phpbasics/ss/mysql_files_2.htm
Reputation Points: 10
Solved Threads: 0
Light Poster
swaters86 is offline Offline
26 posts
since Jul 2007
Jul 8th, 2007
0

Re: parse error, unexpected T_STRING in

the purpose of this, is just to check if the SQL table actually exists before you INSERT data into it. If you're sure that the table exists (that you've created it), then you won't need this, its just to stop noobies from doing insert's into a table that doesnt' exist
Reputation Points: 35
Solved Threads: 5
Junior Poster
dr4g is offline Offline
136 posts
since Apr 2007
Jul 8th, 2007
0

Re: parse error, unexpected T_STRING in

I see. I'm lacking knowledge in the basics. Thanks for all your help.

-Newbie
Reputation Points: 10
Solved Threads: 0
Light Poster
swaters86 is offline Offline
26 posts
since Jul 2007
Jul 8th, 2007
0

Re: parse error, unexpected T_STRING in

Any time
Reputation Points: 35
Solved Threads: 5
Junior Poster
dr4g is offline Offline
136 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Simple include() problem
Next Thread in PHP Forum Timeline: Class question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC