SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Location
    Blacksburg, VA
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why do I keep getting this "premature ending of script headers" error?

    I ordered MySQL for my server today, and apparently it is all setup and activated. However, whenever I try to test this script:

    PHP Code:
    #!/usr/local/bin/php
    <?php

        $user 
    "<snip>";
        
    $pass "<snip>";
        
    $db "<snip>";
        
    $link mysql_connect"mercury.powweb.com"$user$pass );
        if ( ! 
    $link )
            die( 
    "Couldn't connect to the MySQL server." );
        print 
    "Successfully connected to the MySQL server." );
    mysql_select_db $db )
        or die ( 
    "Couldn't open $db: ".mysql_error() );
    print 
    "Successfully opened the database \"$db\"<P>";
    mysql_close$link );
    ?>
    I just get a server 500 internal error, and because of my gay server's configuration, I have to then go and download the error log to see what actually happened.
    It says in the error log that "premature ending of script headers".

    WTF is that?
    By the way, I have to have the #!/usr/local/bin/php line at the very top of my page because my gay host runs PHP as a CGI exe.

    Anyway, any help would be appreciated, thanks.

  2. #2
    SitePoint Member
    Join Date
    Apr 2002
    Location
    Blacksburg, VA
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If anyone has any recommendations for a good PHP and MySQL webhost with good features, feel free to post what you have.

  3. #3
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should really ask that in the web hosting forums but i'll point you to www.phenominet.com anyway

  4. #4
    SitePoint Member
    Join Date
    Apr 2002
    Location
    Blacksburg, VA
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, could you help me with the script error too?

  5. #5
    SitePoint Member
    Join Date
    May 2002
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    $mysql_host 
    ""// MySQL hostname
    $mysql_user ""// MySQL username
    $mysql_pass ""// MySQL password
    $dbname "";     // MySQL database name

    $dbconnect mysql_connect("$mysql_host","$mysql_user","$mysql_pass"); // MySQL connection
       
    if(!$dbconnect) {

    echo 
    "You failed to connect to the MySQL server."// Error message
        
    die; // Script dies due to mysql connection returns negative

    }

    $dbselect mysql_select_db("$dbname",$dbconnect); // Database selection
        
    if(!$dbselect) {

    echo 
    "You successfully connected to the MySQL server but the database could not be found."// Error message

    mysql_close($dbconnect); // Closes MySQL connection

    die;

    }

    echo 
    "You successfully connected to the MySQL server and database."// Successfull message

    ?>
    I quickly coded this to debug your problem.

    I tested it before i posted it and it all works.

    .icecube

  6. #6
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Why do I keep getting this "premature ending of script headers" error?

    Originally posted by CDM_ipGamer
    because of my gay server's configuration
    ...
    my gay host runs PHP as a CGI exe.
    <political_correctness>you shouldn't use "gay" as a derogatory term. is there something wrong with "gay?"</political_correctness>

    anyway, did PHP scripts work before MySQL was installed/enabled on the server? i wouldn't think MySQL would make a difference... "premature ending of script headers" probably means that php.exe isn't returning the default "Content-type: text/html\n\n" Content-type header.

    you could try adding this before you output any HTML in your scripts

    PHP Code:
    header('Content-type: text/html'); 
    but you should have your host look at this and try to fix it. BTW, what's the Web server software?

    for hosts, i use VenturesOnline. they're awesome.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  7. #7
    SitePoint Member
    Join Date
    May 2002
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Re: Why do I keep getting this "premature ending of script headers" error?

    Originally posted by DR_LaRRY_PEpPeR


    did PHP scripts work before MySQL was installed/enabled on the server? i wouldn't think MySQL would make a difference... "premature ending of script headers" probably means that php.exe isn't returning the default "Content-type: text/html\n\n" Content-type header.

    you could try adding this before you output any HTML in your scripts

    PHP Code:
    header('Content-type: text/html'); 
    hmmmmmm.

    we'll see if that code i gave him worked. if it dosnt then we know its the PHP conf.

    i didnt take time to look at his code and debug so it may be his PHP conf.

    .icecube


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
  •