SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2006
    Location
    Duesseldorf -Germany
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP/MySQL Connection

    hi,
    i'm using php5.0 and MySQL4.1. i receive only a white screen on my browser anytime i try to retrieve data from mysql using php.i think the connection to my mysql with php is made (otherwise i will receive an error message) but still don't see anything. can someone help me. Below is excerpts of the code:

    // Connect to the database server
    $database_connect = @mysql_connect('localhost', 'root', 'strech');
    if (!$database_connect) {
    exit('<p>Unable to connect to the ' .
    'database server at this time.</p>');
    }

    // Select the database named as 'uni' in mysql
    if (!@mysql_select_db('uni')) {
    exit('<p>Unable to locate the uni ' .
    'database at this time.</p>');
    }

    // the uni database contains a table named as students with a
    // column named as student_text. this column is what i want to retrieve

    echo '<p>Here are all the students list in our database/p>';

    // Request the text of all the students
    $result = @mysql_query('SELECT student_text FROM students');
    if (!$result) {
    exit('<p>Error performing query: ' .
    mysql_error() . '</p>');
    }
    // Display the text of each student in a paragraph
    while ($row = mysql_fetch_array($result)) {
    echo '<p>' . $row['student_text'] . '</p>';
    }

    hope you guys can help me now.thanx

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    remove all the @ symbols, they silence errors. errors are good to see when debugging.

  3. #3
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not going to fix your problem (I don't think), but I'd recommend either switching mysql_fetch_array() out for mysql_fetch_assoc or using the second parameter to mysql_fetch_array to pass MYSQL_ASSOC; either of these methods will give you only the associative array that you are using. Your current method doubles the amount of memory required to store the result row because it is stored in both a numbered array and an associative array.


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
  •