Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP 5.0 , MySQL 5.0 problem

    Hi.. I am using php 5.0, MySql 5.0 and IIS 5.1
    I can run normal php pages but when i try to connect to MySql Server to display some data using tables, nothing is displayed. blank screen. i wonder y...hope anyone for noes this, can enlighten me.?


    here are the php codes


    <?php
    echo "HI";
    $connection = mysql_connect("localhost","root","")
    or die ("couldn't connect to server");
    mysql_error();

    $db = mysql_select_db("property", $connection)
    or die ("Couldn't select database");

    $query = "SELECT * FROM new" ;
    $result = mysql_query($query)
    or die("Query Failed: ".mysqli_error());

    echo "<table border ='1'>";
    echo "<tr>";
    echo "<th>Date</th><th>Contact</th><th>Name</th><th>Project Name</th><th>Area</th><th>Room Type</th>
    <th>Price</th><th>Availability</th><th>Remarks</th><th>Block</th><th>Unit / Level</th>";

    while ($row = mysql_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>", $row['Date'], "</td><td>",
    $row['Contact'], "</td><td>",
    $row['Name'], "</td><td>",
    $row['ProjectName'], "</td><td>",
    $row['Area'], "</td><td>",
    $row['RoomType'], "</td><td>",
    $row['Price'], "</td><td>",
    $row['Availability'], "</td><td>",
    $row['Remarks'], "</td><td>",
    $row['Blk'], "</td><td>",
    $row['UnitOrLevel'], "</td>";
    echo "</tr>";
    }

    echo "</table>";

    mysql_close($connection);



    ?>
    Last edited by akimoto82; 01-03-2007 at 10:27 AM.

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Hmm... You are saying that you don't even get to see 'HI' being printed. What have you done to debug? Are error messages on? If not add at the top of your script
    PHP Code:
    <?php
    error_reporting
    (E_ALL);
    /* your  script */
    ...
    ?>
    display_errors has to be on though. Use e.g. phpinfo(); to see if this is the case.

    If it isn't possible to get error messages, remove one statement at a time from the bottom until you get to see 'HI'. Then post again your minimal script that isn't working.
    Last edited by koyama; 01-03-2007 at 08:22 AM. Reason: typo

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have added error_reporting(E_ALL); to my coding but still the same..I can the word HI , but the others simply cannot view.. I dunno y also..

    Not even any error messages..

  • #4
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Well if it prints 'HI' then you don't have any parse errors at least.

    What about the html that was sent. If you say 'View Source' from your browser, do you see an empty table?

    What do you see when you run this?
    PHP Code:
    <?php
    error_reporting
    (E_ALL);
    echo 
    "HI";
    $connection mysql_connect("localhost","root","");
    $db mysql_select_db("property"$connection);

    $query "SELECT * FROM new";
    $result mysql_query($query);

    $row mysql_fetch_array($result);
    var_dump($row);
    }

    ?>
    Last edited by koyama; 01-03-2007 at 10:43 AM. Reason: typo

  • #5
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    now the word HI is gone also...total blank page....

  • #6
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okok...now the word HI is back again...but still no tables....

  • #7
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Sorry, there was a brace that shouldn't have been there.
    Try:
    PHP Code:
    <?php
    error_reporting
    (E_ALL);
    echo 
    "HI";
    $connection mysql_connect("localhost","root","");
    $db mysql_select_db("property"$connection);

    $query "SELECT * FROM new";
    $result mysql_query($query);

    $row mysql_fetch_array($result);
    var_dump($row);
    ?>

  • #8
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Its still the same.. = (

    Only display the word HI only...

  • #9
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    In that case, I must give up. It makes no sense to me that you only see 'HI' and nothing from the var_dump. Maybe someone else can see what's wrong.

    It seems you have display_errors set to off so we don't get any messages. By the way are you sure your table 'new' isn't empty?

  • #10
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok two things. 1) Do you have data in that table for that database.
    2) what exactly do you get when you view source.

    also in your first code chang the mysqli_error ro mysql_error

    and in the test code you have change it to this
    PHP Code:
    <?php
    error_reporting
    (E_ALL);
    echo 
    "HI";
    $connection mysql_connect("localhost","root","");
    $db mysql_select_db("property"$connection);

    $query "SELECT * FROM new";
    $result mysql_query($query) or die(mysql_error());

    $row mysql_fetch_array($result);
    var_dump($row);
    ?>
    Cheers

  • #11
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sure i have data in the table for the database
    but my source is like this


    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    
    </head>
    
    <body>
    
    HI

  • #12
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    You should probably post your latest code.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #13
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my lastest code for my test app

    PHP
    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    
    </head>
    
    <body>
    
    <?php
    error_reporting(E_ALL);
    echo "HI";
    $connection = mysql_connect("localhost","root","");
    $db = mysql_select_db("property", $connection);
    
    $query = "SELECT * FROM new";
    $result = mysql_query($query) or die(mysql_error());
    
    $row = mysql_fetch_array($result);
    var_dump($row);
    ?>
    
    </body>
    </html>
    my source

    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    
    </head>
    
    <body>
    
    HI
    i just nid to make sure my the connection from php to mysql can work...now currently i'm just seeing blank pages except for the word "HI"

  • #14
    New Coder
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it also got to do with some software configurations that i need to do?

  • #15
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    Because your output does not have the HTML tags that are at the end of the file, I suspect that the PHP code stops executing due to an error, but that error output is off on your server. Try adding the following line after your opening <?php tag -
    PHP Code:
    ini_set('display_errors'1); 
    If you have access to your server log file, also check it.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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