parse error, unexpected T_STRING in

Reply

Join Date: Jul 2007
Posts: 26
Reputation: swaters86 is an unknown quantity at this point 
Solved Threads: 0
swaters86 swaters86 is offline Offline
Light Poster

parse error, unexpected T_STRING in

 
0
  #1
Jul 8th, 2007
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


  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.

  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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

 
0
  #2
Jul 8th, 2007
What is exactly line 7 within your .php file?
It's just a syntax error, and can be worked out momentarily for you

Cheers.
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 142
Reputation: MitkOK is an unknown quantity at this point 
Solved Threads: 12
MitkOK's Avatar
MitkOK MitkOK is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

 
0
  #3
Jul 8th, 2007
What is this ?!?

  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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

 
0
  #4
Jul 8th, 2007
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
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 26
Reputation: swaters86 is an unknown quantity at this point 
Solved Threads: 0
swaters86 swaters86 is offline Offline
Light Poster

Re: parse error, unexpected T_STRING in

 
0
  #5
Jul 8th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

 
0
  #6
Jul 8th, 2007
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
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 26
Reputation: swaters86 is an unknown quantity at this point 
Solved Threads: 0
swaters86 swaters86 is offline Offline
Light Poster

Re: parse error, unexpected T_STRING in

 
0
  #7
Jul 8th, 2007
I see. I'm lacking knowledge in the basics. Thanks for all your help.

-Newbie
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

 
0
  #8
Jul 8th, 2007
Any time
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC