Closed Thread
Results 1 to 2 of 2

Thread: PHP Help

  1. #1
    Zenax's Avatar
    Zenax is offline Lord Of The Keys Zenax is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    The Brilliant United Kingdom
    Posts
    1,339

    PHP Help

    PROBLEM FIXED! JUST CHANGED THE NAMES OF THE FIELDS IN THE DB AND SCRIPT SO THEY HAD NO SPACES AND IT WORKED!

    ror:

    PHP Code:
    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 Code:
    <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 by Zenax; 04-09-2007 at 09:43 AM.
    Regards,
    Zenax

  2. #2
    Chris Z's Avatar
    Chris Z is offline x10 Spammer Chris Z is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Alabama, USA
    Posts
    2,802

    Re: PHP Help

    OK. So you are no longer in need of help?
    -Chris Z
    Retired Account Manager


Closed Thread

Similar Threads

  1. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  2. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  3. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  4. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  5. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers