SitePoint Sponsor

User Tag List

Results 1 to 18 of 18

Thread: No output

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    No output

    Hi,
    I've created such an HTML file like

    <html>
    <head>
    <title>Selecting MySQL Database</title>
    </head>
    <body>
    <?php
    $dbhost = 'localhost:3306';
    $dbuser = 'created_user';
    $dbpass = 'password';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn )
    {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_select_db( 'created_user' );
    mysql_close($conn);
    ?>
    </body>
    </html>

    But I did not have any output from that. Any advice? When I'm connecting to the DB using dbForge studio, I don't have problem at all (see the screen shots)
    http://www.4shared.com/file/20007484...in_screen.html
    Many Thanks & Best Regards,
    HuaMin Chen

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,699
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    What do you see when you enable error reporting?

    Code php:
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks Paul. I've put that. Now it's like

    <html>
    <head>
    <title>Selecting MySQL Database</title>
    </head>
    <body>
    <?php
    error_reporting(E_ALL);
    $dbhost = 'localhost:3306';
    $dbuser = 'created_user';
    $dbpass = 'password';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn )
    {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_select_db( 'created_user' );
    mysql_close($conn);
    ?>
    </body>
    </html>

    but I still see any output.
    Many Thanks & Best Regards,
    HuaMin Chen

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,699
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Are you able to see anything when you have only the following as the php content?

    PHP Code:
    <?php
    echo phpinfo();
    ?>
    If not, it might be the php settings that need to be tinkered with.

    Speaking of which, what is your server environment?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many many thanks.
    I've put that like this

    <html>
    <head>
    <title>Selecting MySQL Database</title>
    </head>
    <body>
    <?php echo phpinfo(); ?>
    <?php

    error_reporting(E_ALL);
    $dbhost = 'localhost:3306';
    $dbuser = 'created_user';
    $dbpass = 'password';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn )
    {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_select_db( 'created_user' );
    mysql_close($conn);
    ?>
    </body>
    </html>

    this is called index.html and it's put in D:\xampp\htdocs\mysite2

    But when I call this http://localhost/mysite2, I still see nothing.

    At the same time, I have another set of site programs in D:\xampp\htdocs\mysite and I can locate to the starting page of that, by http://localhost/mysite.
    Many Thanks & Best Regards,
    HuaMin Chen

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,699
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    I haven't used xampp before, but the standard for php files is to call them index.php

    You might be running the risk that index.html is not being interpreted.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For that set of previous programs, I see that there's only index.html (and no index.php). Any advice for that the above file is not showing anything?
    Many Thanks & Best Regards,
    HuaMin Chen

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,699
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    My advice is that your php code is not responsible for the problem.

    You will need to look further into the server setup, to resolve your issue.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. But do you see anything wrong in the above file?
    Many Thanks & Best Regards,
    HuaMin Chen

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,699
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by HuaMin View Post
    Thanks. But do you see anything wrong in the above file?
    As I said before, there is nothing wrong with the contents of file. The issue that you're facing is not related to the contents of the file. The issue that you seem to be facing is that the server refuses to interpret it as PHP code.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #11
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Paul has already told you the cause of the problem.
    XAMPP Puts an index.html file in the root directory. This file is a simple frameset and so has no PHP code on it.

    Rename your file to index.php and it will run fine.
    It needs to be named with a php extention so that it can be parsed by the server before being sent to the browser.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  12. #12
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks to all. I've renamed the file (to be index.php) and now when going to thishttp://localhost/mysite2/

    I've got this page

    http://www.4shared.com/file/20202205..._Database.html
    Many Thanks & Best Regards,
    HuaMin Chen

  13. #13
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Good stuff, that means its working fine.

    Remove the
    Code:
    <?php echo phpinfo(); ?>
    and you will be left with the last line
    1Connected successfully
    which is good
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  14. #14
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many many thanks. By the way, how can I export/import one Mysql user?
    Many Thanks & Best Regards,
    HuaMin Chen

  15. #15
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,699
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    http://www.apachefriends.org/en/xamp...ml#configfiles
    It says that the configuration for MySql is at \mysql\bin\my.ini

    So far as setting/changing the password, check out http://www.apachefriends.org/en/faq-...html#password1
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  16. #16
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The 2 links are not available now. How to import one schema/user?
    Many Thanks & Best Regards,
    HuaMin Chen

  17. #17
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,699
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    The two links that I provided work perfectly well.

    You will experience problems though when you copy/paste the text description for the link, because the Forum itself puts in the ellipses so that they don't take up too much room.

    If all else fails, perform a search for xampp add mysql user and choose the first link that is for apache friends - xampp for windows
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #18
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Location
    China
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many many thanks. Could you pls help on this?
    http://www.sitepoint.com/forums/showthread.php?t=657016
    Many Thanks & Best Regards,
    HuaMin Chen


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
  •