0

I get these errors in a script of mine:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\www\vhosts\myradiostation\test.php on line 13

and my original page (included in another page):

<?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 get the MySQL and PHP to work properly with this?

Edited by whitestream6: n/a

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by DW Master
0

This line:

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

should be:

$result = mysql_query("select * from presenters");
0

I got another error, the error being this:

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

.
Here's my code:

<?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>";
	}
	?>

Edited by whitestream6: n/a

0

I got another error, the error being this:
.
Here's my code:

<?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>";
	}
	?>

execute the

select * from presenters

directly into the MySQL , and see if there you get the same error, then you must check with your table name.
If such table even exists or not.

0

try to use mysql_error in query to confirm if your query is valid or not,
Example:

...
//select the table
$result = mysql_query("select * from presenters")or die(mysql_error());
...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.