Results 1 to 5 of 5

Thread: PHP and Mysql Error

  1. #1
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default PHP and Mysql Error

    Hi gus, I was just starting a script that retreves data from a mySql database ( I know... basic right) but I keep getting this error:
    Code:
    Fatal error: Call to undefined function mysql_connect() in C:\a\directory\here\members.php on line 11
    Here's the code on members.php (unfinished btw)
    PHP Code:
    Results: 
    <?php
    $cat 
    $_GET['cat'];
    $host="http://a-host-here.url"// Host name 
    $username="my-username"// Mysql username 
    $password="my-password"// Mysql password 
    $db_name="a-database-name"// Database name 
    $tbl_name="a-table-name"// Table name 

    // Connect to server and select database.
    mysql_connect("$host""$username""$password")or die("Sorry, cannot connect to the database."); 
    mysql_select_db("$db_name")or die("Sorry, cannot select the database");

    // Retrieve data from database 
    $sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);

    // Start looping rows in mysql database.
    while($rows=mysql_fetch_array($result)){
    ?>
    <table width="400" border="1" cellspacing="0" cellpadding="3">
    <tr>
    <td width="10%"><? echo $rows['last']; ?></td>
    <td width="30%"><? echo $rows['first']; ?></td>
    <td width="30%"><? echo $rows['website']; ?></td>
    <td width="30%"><? echo $rows['email']; ?></td>
    </tr>
    </table>

    <?
    // close while loop 
    }

    // close connection 
    mysql_close();
    ?>
    What is wrong, and why doesn't it trigger the "or die" after it if it cannot connect?
    Thanks,
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    It seems that your php install is not recognizing mysql_connect as a "built-in" function. Make sure that the mysql extension is enabled in your php.ini file. If you do not have access to that file, talk to your host.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    And this is the exact same problem I'm having here: http://www.dynamicdrive.com/forums/s...ad.php?t=30976

    -Josh
    - Josh

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Jshor,
    I just responded to your thread. Please keep any further issues regarding this matter in that thread.

    Thanks
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    got it, thansk!
    - Josh

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •