what is wrong with my code? new to php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fastmike
Forum Commoner
Posts: 32
Joined: Wed Jan 24, 2007 12:52 am

what is wrong with my code? new to php

Post by fastmike »

this is my code.

Code: Select all

<?php
   // (1) Open the database connection
   $connection = mysql_connect("localhost","root","secret");

   // (2) Select the winestore database
   mysql_select_db("winestore", $connection);

   // (3) Run the query on the winestore through the connection
   $result = mysql_query ("SELECT winery_name
   , phone, fax from winery", $connection);
   while($row = mysql_fetch_array($result))
   {
      print "THe {$row["winery_name"]} winery's fax is {$row["fax"]}";
      print "Their phone is {row["phone"]}.\n";
      }


?>
error

Code: Select all

Parse error: parse error, unexpected T_STRING in c:\program files\easyphp1-7\www\index12.php on line 24
any help will be appreciated.
Thanks
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

which line is line 24? also, what's on line 23?
fastmike
Forum Commoner
Posts: 32
Joined: Wed Jan 24, 2007 12:52 am

Post by fastmike »

Code: Select all

print "THe {$row["winery_name"]} winery's fax is {$row["fax"]}";
this is line 24 sorry i did not include my html code.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

try:

Code: Select all

print "THe {$row['winery_name']} winery's fax is {$row['fax']}";
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Mike, hopefully you have a program that color codes things like that for you in php. Especially as a new coder, that's an easy mistake to make. If you can't afford anything that's big (or don't want to spend the money), maybe you could try Vim?
fastmike
Forum Commoner
Posts: 32
Joined: Wed Jan 24, 2007 12:52 am

Post by fastmike »

Thanks huggins works like a charm. i have another question but it is totally different so i will post it as a new topic.
Thanks alot though.
fastmike
Forum Commoner
Posts: 32
Joined: Wed Jan 24, 2007 12:52 am

Post by fastmike »

thanks superdesign i will try that VIM. may i ask my question in this post or can i post a whole new topic?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

It's best to post a new topic.

I use Editplus in Windows, but there's a topic for that as well - search for "php editor"
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Mike, try Kieran's. It's much more user-friendly, especially to someone newer to php. Vim is a lot like a command-prompt, and the only reason I know it exists is from puTTy.
Post Reply