User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 402,003 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,368 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1756 | Replies: 7
Reply
Join Date: Jul 2007
Posts: 25
Reputation: swaters86 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
swaters86 swaters86 is offline Offline
Light Poster

Troubleshooting parse error, unexpected T_STRING in

  #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


 

<?
$artist=$_POST['artist'];
$song=$_POST['song'];
$album=$_POST['album'];
mysql_connect("localhost", "swaters210", "password") or die(mysql_error());
mysql_select_db("swaters210") or die(mysql_error());
CREATE TABLE data (artist VARCHAR(30), song VARCHAR(30), album VARCHAR(30));
mysql_query("INSERT INTO `data` VALUES ('$artist', '$song', '$album')");
Print "Your information has been successfully added to the database.";
?>

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

<form method="POST" action="music.php">
<label for="artist"><b>Artist Name:</b></label>
<input type="text" name="artist" value="" /><br />
<label for="song"><b>Song Title:</b></label>
<input type="text" name="song" value="" /><br />
<label for="album"><b>Album:</b></label>
<input type="text" name="album" value="" /><br />
<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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

  #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  
Join Date: Jul 2007
Location: Sofia, Bulgaria
Posts: 138
Reputation: MitkOK is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
MitkOK's Avatar
MitkOK MitkOK is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

  #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 8:58 am.
Reply With Quote  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

  #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  
Join Date: Jul 2007
Posts: 25
Reputation: swaters86 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
swaters86 swaters86 is offline Offline
Light Poster

Re: parse error, unexpected T_STRING in

  #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  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: parse error, unexpected T_STRING in

  #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  
Join Date: Jul 2007
Posts: 25
Reputation: swaters86 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
swaters86 swaters86 is offline Offline
Light Poster

Re: parse error, unexpected T_STRING in

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

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

Re: parse error, unexpected T_STRING in

  #8  
Jul 8th, 2007
Any time
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:19 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC