Results 1 to 6 of 6

Thread: why doesn't the text appear in browseR? HELP NEEDED!

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    why doesn't the text appear in browseR? HELP NEEDED!

    why doesnt the text "success" appear in the browser? when i execute this code, they did not give me any error message, instead they just give me a blank screen. issit probably because of my connection to MYSQL? or issit there is something wrong with the code?

    These are the codes i am referring to.

    <?
    $connection = mysql_connect("localhost", "lina", "lina") or die (mysql_error());
    if ($connection){
    $msg = "success!";
    }
    ?>

    <html>
    <head>
    <title>MY SQL</title>
    </head>
    <body>

    <?echo "$msg"; ?>

    </body>
    </html>

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: why doesn't the text appear in browseR? HELP NEEDED!

    is the rest of the code (the HTML you put there) being output? check the source of the page to make sure.

    just as a side note: you might want to try it without if() statement to define $msg. since you have an "or die()" statement on your call to mysql_connect(), if there is no connection the script will just end, outputting any errors returned by mysql as to why a connection wasn't made. after your call to mysql_connect(), $connection should always be valid (although, I'm not so sure in this case). you can try this small script instead, which does basically the same thing (from php.net):
    PHP Code:
    <?php
    $link 
    mysql_connect('localhost''mysql_user''mysql_password');
    if (!
    $link) {
       die(
    'Could not connect: ' mysql_error());
    }
    echo 
    'Connected successfully';
    mysql_close($link);
    ?>

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    Re: why doesn't the text appear in browseR? HELP NEEDED!

    i have tried using the code u have given to me. but there is still error. the error statement is this: PHP Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\fypj\lalala.php on line 3.

    i have check the username and the password of my mysql database. it is all correct. but why there is an error on that line?

    issit probably because there is something i shud do to my MYSQL database or there is something wrong with the code?

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: why doesn't the text appear in browseR? HELP NEEDED!

    looks like you don't have the mysql extension enabled. do you know what version of php you're using?

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    58

    Re: why doesn't the text appear in browseR? HELP NEEDED!

    i am using PHP version 5. so what should i do to solve the problem?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: why doesn't the text appear in browseR? HELP NEEDED!

    If you're running PHP locally, the MySQL extension should be enabled by default. However, you might have to enable it manually: in php.ini, add the line (on Windows):
    Code:
    extension=php_mysql.dll
    If you're on a hosted account, ask your administrator to enable it. Alternatively, you might have to use an alternative method of connecting to the database, such as MySQLi, MDB2, PDO, etc. The standard php_mysql extension is rather primitive; you should use one of those alternatives if you can anyway.

Posting Permissions

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



Click Here to Expand Forum to Full Width