Page 1 of 1

what is wrong with my code? new to php

Posted: Wed Jan 31, 2007 8:38 pm
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

Posted: Wed Jan 31, 2007 8:53 pm
by Kieran Huggins
which line is line 24? also, what's on line 23?

Posted: Wed Jan 31, 2007 8:58 pm
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.

Posted: Wed Jan 31, 2007 9:42 pm
by Kieran Huggins
try:

Code: Select all

print "THe {$row['winery_name']} winery's fax is {$row['fax']}";

Posted: Wed Jan 31, 2007 9:53 pm
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?

Posted: Wed Jan 31, 2007 9:54 pm
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.

Posted: Wed Jan 31, 2007 9:57 pm
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?

Posted: Wed Jan 31, 2007 10:37 pm
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"

Posted: Wed Jan 31, 2007 10:42 pm
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.