0

I have read through the FAQ sticky regarding this topic (and have also searched/read here further on this topic) but I am still receiving the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a4542527/public_html/index.php on line 8

The scripting for this is basic at this point (I am building something in steps and this is just a test section: The script will call data from the table and display said data.)

The following is the code (two, separate files located on my server)- I am hoping that someone may see something that I am missing.

connection.php

<?php
    $dbhost = 'mysql7.000webhost.com';
    $dbuser = 'a4542527_root';
    $dbpass = '**********';
    
    $db = 'a4542527_test1';
    $conn = mysql_connect($dbhost,$dbuser,$dbpass);
    mysql_select_db($db);

?>

index.php

<?php
    include 'connection.php';
    
    $query = "SELECT * FROM people";
    
    $result = "mysql_query($query)";
    
    while ($person = mysql_fetch_array($result)){
    echo  $person ['name'];
    echo  $person ['descrip'];
    }
?>

Thank-you for any help, suggestions or a point in the right direction.
Matty

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by richieking
1

change:
$result = "mysql_query($query)"; to:
$result = mysql_query($query) or die( mysql_error() );

0

your connection MAY not be proper, or else the sql query is returning some error for sure.

0

or else the sql query is returning some error for sure

which query? He did NOT query the db at all! He simply assigned a string to $result. He needs to remove the red quotation marks I pointed out from line 6 on his second code block.

0

Its coding, very little character counts.

$result = "mysql_query($query)";

no need for the " " sign.
;)

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.