Jump to content

mysql_fetch_array Problem...


jeva39

Recommended Posts

Hello

I use this simple code to try something in my Web Server (Using PHP 4.4 and mySql 4.1):


[code]<?php
$con = mysql_connect("localhost", "username", "pass");
mysql_select_db("jv");

$query  = "SELECT tema, ritmo FROM temas where ritmo='BALADA' order by tema";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_NUM)) // Line 8
{
    echo "Tema : {$row[0]} " . " Ritmo : {$row[1]} <br>";
}

mysql_close($con);

?>[/code]

But I receive this error:

[color=red]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\Inetpub\vhosts\prolatin.com\httpdocs\php\jv_mysql.php on line 8 [/color]


The Database don't have problem. Please do you can help me what is wrong?

In my computer all run OK.

Thanks in advanced....
Link to comment
https://forums.phpfreaks.com/topic/21808-mysql_fetch_array-problem/
Share on other sites

try this...
[code=php:0]<?php
$con = mysql_connect("localhost", "username", "pass");
mysql_select_db("jv");

$result = mysql_query("SELECT tema, ritmo FROM temas where ritmo='BALADA' order by tema") or die('Result Error: '.mysql_error().'');

while($row = mysql_fetch_array($result, MYSQL_NUM)) // Line 8
{
    echo "Tema : {$row[0]} " . " Ritmo : {$row[1]} <br>";
}

mysql_close($con);

?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.