SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql_connect stalls on call

    I'm trying to learn some MySQL4.0.20a-nt + PHP5 and when the mysql_connect function is called, it hangs / stalls and nothing else after the statement call works. I can do echo "This is a string."; and it'll print that out just fine (but only before the mysql_connect call). I know the host / user / password are correct and I know I can connect to MySQL on DOS prompt and with MySQL Administrator. Maybe I installed PHP incorrectly? I know "echo" works and including other files works so I must have done something write with the installation of PHP. Any suggestions on what the problem might be?

    Also, I'm just learning still. I don't know much about MySQL or PHP and I'd like to learn some more so don't slam me for something I have not caught yet that most PHP / MySQL'ers catch easily. Thanks.

  2. #2
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try something like this
    PHP Code:
    mysql_connect($host$user$password) or die(mysql_error()); 

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by maxor
    try something like this
    PHP Code:
     mysql_connect($host$user$password) or die(mysql_error()); 
    Ok I tried this:
    PHP Code:
     <?php
         
    echo ("...");
         
    $host "localhost";
         
    $user "root";
         
    $pass "root_password";
         
    $dbcnx mysql_connect($host$user$pass) or die(mysql_error());
     
    ?>
    and I got the same odd occurence. If I'm using an unknown function, what should happen? I randomly changed mysql_connect() to mysql_conne() just to see if it would do anything and it did the same stalling thing.

  4. #4
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you say the script 'stalls' do you mean that it actually fails or dies, or it's hung up. How do you know that it's 'stalling'?

    What happens when you execute this code...

    PHP Code:
    <?php

    $i 
    1;

    while( 
    $i 20 ){

      if(
    $i == 10){
        
    $dbcnx mysql_connect("localhost""root""root_password") or die(mysql_error());
        }

    echo 
    'The Value of I is : '.$i.'<br />';

    $i ++;

    }
    ?>

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It displays nothing.
    When you say the script 'stalls' do you mean that it actually fails or dies, or it's hung up. How do you know that it's 'stalling'?
    By stalling, I mean it doesn't do anything. Any amount of "echo" statements after the mysql_connect() call are not displayed. It only goes to the mysql_connect() call and then doesn't execute the rest of the code. I hope thats a good enough explaination. Let me know if I'm still confusing you.

    By the way, thanks for helping.

  6. #6
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you've got error reporting off.

    Do you have access to your php.ini file?

    What is the value of the 'display_errors' directive?

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's currently set to "Off." I suppose I should change it to "On"? I'll go ahead and try it and see what happens.

    EDIT: I changed it to "On" and it still doesn't do anything different.

  8. #8
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does the following code display...

    PHP Code:
    echo 'Before the connection';

    // Add your connection here

    echo 'After the connection'

  9. #9
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It just outputs "Before the connection".

  10. #10
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by treble54
    It just outputs "Before the connection".
    Try:

    PHP Code:
      ini_set('display_errors'1);
      
    error_reporting(E_ALL); 
    At the top of your script.
    My name is Steve, and I'm a super-villian.

  11. #11
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah! That helped! I got this:
    Before the connection
    Fatal error: Call to undefined function mysql_connect() in X:\My Documents\htdocs\test.php on line 9
    And Line 9 refers to:
    $dbcnx = mysql_connect($host, $user, $pass) or die(mysql_error());
    with $host, $user, and $pass all correctly set. Maybe that helps fix the problem. I think I've seen a similar problem elsewhere.

  12. #12
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    ecuador
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see you are using php5 (latest release ? )
    did you include php_mysql.dll or php_mysqli.dll ???

    for the fun of it.
    PHP Code:
    #try
    $dbcnx mysqli_connect($host$user$pass) or die(mysql_error()); 

  13. #13
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I know, I wrote that in the beginning of the first post of this thread. How do I include that file?

  14. #14
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    ecuador
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats done in ure php.ini

    around line 565, replace that line with the following
    extension=php_mysql.dll
    Than restart ure apache
    PHP Code:
    <?
    #see if mysql shows up anywhere
    phpinfo();
    ?>

  15. #15
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok well I uncommented that line in the php.ini file. Now where does the php_mysql.dll go? I suppose it goes in the C:\Windows\ directory. Forgive my dumbfoundedness. I'm new to all of this.

    When I restart it, it says it can't find the './php_mysql.dll' file.

  16. #16
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Kansas
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ol4pr0
    see you are using php5 (latest release ? )
    did you include php_mysql.dll or php_mysqli.dll ???

    for the fun of it.
    PHP Code:
     #try
     
    $dbcnx mysqli_connect($host$user$pass) or die(mysql_error()); 
    The mysqli_connect() call didn't work either.

  17. #17
    SitePoint Enthusiast wallyweb's Avatar
    Join Date
    Oct 2003
    Location
    Saint John, NB, Canada
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysqli_connect() issue

    I know this thread has been quiet for a while (since 2004?) but I found it when doing a search for a similar issue.
    I resolved my problem and I wonder if that is what was happening here.
    I was testing my file on localhost and the php was not php'ing (new word? credit me )
    The same code was working in another file. What was the difference?
    It took a jug of coffee and 3 packs of cigarettes before I clued in:

    Loading into my browser:

    Bad file:

    Code:
    file:///J:/Apache%20Group/Apache2/htdocs/foo
    Good file:

    Code:
    http://localhost:8080/foo
    Hope this helps someone else (next year?)
    Last edited by wallyweb; May 1, 2005 at 08:46. Reason: missing step


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
  •