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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.