php problems with godaddy?

Discussion in 'Web Design and Development' started by chainprayer, Jan 8, 2009.

  1. chainprayer macrumors 6502a

    Joined:
    Feb 10, 2008
    #1
    anyone else ever have any problems using php with godaddy? i have a simple php script set up to connect to my sql database. when there is an error in the code it returns a blank page instead of an error with a reference to the error line. anyone else have this happening?
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    If GoDaddy doesn't give you access to the PHP error log file then you can try to catch the errors using try..catch and/or die statements.
     
  3. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #3
    A blank page usually means a "fatal" error such as a typo in a function name, missing ; on the end, syntax error as the script is intepreted.

    You can trap (PHP4:most, PHP5: almost all) errors with set_error_handler() callback function but be sure to read the exceptions and notes on this page at php.net.
     
  4. CANEHDN macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #4
    You could post some of your code and maybe we could help you.
     
  5. DipDog3 macrumors 65816

    DipDog3

    Joined:
    Sep 20, 2002
    #5
    I second this. Check that all lines of codes end with ; and that all comments are probably commented.

    When I can't find the problem, I will comment out sections of the code until the PHP file runs, then I can narrow down the problem.
     
  6. IanTheLesser macrumors newbie

    Joined:
    Aug 4, 2010
    #6
    checking database access

    I can relate -- I've had issues I still don't understand with GoDaddy's php server, and I have some background with php and am using a Linux server, not the Windows flavor.

    Here's a few things that can help, though:

    (hopefully not restating the obvious) Try queries first from GoDaddy's phpMyAdmin, which you can get to from the Hosting control panel by selecting Databases, clicking on MySQL, and going through the login if you've got your DB's set up. Sometimes this can reveal details missed on the code side, where you're usually dealing with inline SQL.

    Make sure that if you use any $_POST or $_GET variables in your query and are using double quotes or heredoc, you enclose them in curly brackets. If they're string values, put the curly brackets inside the quotes that go into the SQL.

    Finally, even if you don't have access to the error log file directly, I found out recently that php has nifty functions just to check this kind of thing -- it would work something like this:

    Code:
    <?php
    //assuming connection has already been made and DB selected
    $result = mysql_query($query, $connection);
    if (!$result) {
    $report = 'Query failed for the following reason: <br />';
    $report.= mysql_errno($connection). ": ";
    $report.= mysql_error($connection);
    echo $report
    //alternately, if this is a backend process like PayPal IPN,
    //you could use mail($recipient, "Query Failed", $report)
    }
    ?>
    
    Hopefully this is helpful.
     
  7. harpster macrumors regular

    Joined:
    Jan 26, 2010
    #7
    You might have an error in your SQL statements and often that will not output an error message. You can use the "die" statement combined with "mysql_error" as in the following two examples. Either one with your connect values should output an error if there is one.

    PHP:
    <?php
    $link 
    mysql_connect('localhost''mysql_user''mysql_password');
    if (!
    $link) {
        die(
    'Could not connect: ' mysql_error());
    }
    echo 
    'Connected successfully';
    mysql_close($link);
    ?>

    PHP:
    <?php
    mysql_connect
    ("localhost""mysql_user""mysql_password") or die(mysql_error());
    echo 
    "Connected to MySQL<br />";
    ?>

    Also to see if display_errors is working for php (not the mysql part) just make an even simpler php file with 2 or 3 lines and test by messing up something. I'm sure you will see an error message generated.
     

Share This Page