MySQL Select

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
paulytrick
Forum Newbie
Posts: 8
Joined: Mon May 11, 2009 1:40 pm
Location: Sheffield, UK

MySQL Select

Post by paulytrick »

Hi, can anyone help me out with the following code?

It's meant to slelect each row from the 2 specified cloumns and output it to the web page. all I get is a blank web page.
i don't know whats happening, is the loop breaking before the first result is being displayed?
Thee is data in the rows I have specified and the db and table names are correct.
Many thanks in advance.

Code: Select all

<?
 
mysql_connect("localhost", "root", "****") or die(mysql_error());
mysql_select_db("tackle_shops") or die(mysql_error());
 
 
$result = mysql_query("SELECT * FROM shops")
or die(mysql_error());  
 
 
$row = mysql_fetch_array();
 
 
while($row = mysql_fetch_array($result)){
    echo $row['name']. " - ". $row['town'];
    echo "<br />";
    or die(mysql_error));
    
 
?>
Regards,

Paul.
User avatar
paulytrick
Forum Newbie
Posts: 8
Joined: Mon May 11, 2009 1:40 pm
Location: Sheffield, UK

Re: MySQL Select

Post by paulytrick »

It's ok, I've solved it. I missed a paranthases from the last statement.

thanks for looking
Post Reply