It is currently Wed Feb 08, 2012 5:49 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problem with PHP/MySQL - error message on line 13
PostPosted: Mon Dec 14, 2009 2:34 pm 
Offline

Joined: Mon Dec 14, 2009 2:31 pm
Posts: 3
I get this error in my PHP script (which is included as a file within a main PHP file):
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\www\vhosts\myradiostation.co.uk\showfile.php on line 13


This is the full code of the script (line 13 is highlighted in bold text):
Quote:
<?php
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","PASSWORDREMOVED");

//select which database you want to edit
mysql_select_db("myradio");

//select the table
$result = mysql_query("select * from presenters");

//grab all the content
while($r=mysql_fetch_array($result))
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
{
$shows=$r["shows"];
$onair=$r["onair];
$images=$r["image"];
$showdesc=$r["showdesc"];
echo "<div class=\"divider\"></div>
<div class=\"main\" style=\"width:552px;\">
<img src=\"$images\" width=115 height=60>
<div class=\"time\">$onair</div>
<div class=\"show\"><h3><b>$shows</b></h3>
<p>$showdesc</p></div>
<div class=\"footer\"></div>
</div>";
}
?>


How do I fix this error myself - I have tried to look it up on Google and fix it myself, but so far I haven't had much luck!

I'm running Apache on localhost, if that's of any interest, with PHP 5.25.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 14, 2009 6:22 pm 
Offline

Joined: Sun May 02, 2004 11:34 pm
Posts: 6500
Location: toronto, canada
Its usually an error in the query or connection. Try this

Code:
$result = mysql_query("select * from presenters") or die(mysql_error());

_________________
Lostboy

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron