PHP Help

Status
Not open for further replies.

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
PROBLEM FIXED! JUST CHANGED THE NAMES OF THE FIELDS IN THE DB AND SCRIPT SO THEY HAD NO SPACES AND IT WORKED!

ror:

PHP:
Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in G:\VertrigoServ\www\dynamic-websites\fbe\dynamic\index.php on line 31

Code:
PHP:
<title>Test Connection</title>
<?php
$username = "root";                // Username Variable
$password = "jessica1";            // Password Variable
$hostname = "localhost";        // The Host Name Variable


$dbh = mysql_connect($hostname, $username, $password)         // The Server Connection string
    or die("Unable to connect to MySQL");                    // Error to display if anything goes wrong
print "Connected to MySQL<br />";                            // What to print if it works

$selected = mysql_select_db("fbe-dynamic",$dbh)             // Connects to the database
    or die("Could not select fbe-dynamic");                    // Error to display if anything goes wrong
print "Connected to fbe-dynamic<br />";                        // What to print if it works!
        

$style = mysql_query("SELECT stylesheet FROM style");        // Queries the sdatabase for the stylesheet table 
while ($stylerow = mysql_fetch_array($style,MYSQL_ASSOC))     // Chooses the row

print $stylerow{'stylesheet'};                                // Prints out the stylesheet to the page


$result = mysql_query("SELECT header FROM header");            // Queries the database for the header table
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {        // Chooses the correct row

print $row{'header'};                                        // Prints the header row
}


$news = mysql_query("SELECT News Title,News Header FROM news");
while ($newsrow = mysql_fetch_array($news,MYSQL_ASSOC)) {

print $newsrow{'News Title'};
print $newsrow{'News Header'};

}




mysql_close($dbh);                                            // Closes the connection
?>

I am a newbie at PHP, so I am attempting a few things, such as database connections etc. Here is some code I wrote. It all works fine apart from the last news bit. Now me thinks is something to do wth the spaces in the names of the table but I could be wrong.

Please help me out!


Oh and if you have any ideas on things I could try as a newbie to help me learn PHP then do let me know!
Regards,
Zenax
 
Last edited:
Status
Not open for further replies.
Top