PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



Problem with PHP/MySQL - error message on line 13

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General
View previous topic :: View next topic  
Author Message
whitestream6



Joined: 14 Dec 2009
Posts: 3

PostPosted: Mon Dec 14, 2009 1:34 pm    Post subject: Problem with PHP/MySQL - error message on line 13 Reply with quote

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[/quote]

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
[b]while($r=mysql_fetch_array($result)) [/b]
//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>";
}
?>[/quote]

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.
Back to top
View user's profile Send private message
lostboy



Joined: 02 May 2004
Posts: 6058
Location: toronto, canada

PostPosted: Mon Dec 14, 2009 5:22 pm    Post subject: Reply with quote

Its usually an error in the query or connection. Try this

[code:1]
$result = mysql_query("select * from presenters") or die(mysql_error());
[/code:1]
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum