mysql errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Bruno

    mysql errors

    Hi,
    I've run a php script that uses mysql databases without problems
    on one server, but then I changed web hosts and installed it the same
    way buy I get a lot of errors which are all derived from the
    script not being able to interact with the database.
    It finds the database and connects, but then can't do anything else.
    When it uses a database on a different server, things work fine,
    so I'm guessing it's just a mysql error and not the fault of the script.

    I'd appreciate any suggestions on how to deal with this.

    thank you,
    David



  • Michael Fuhr

    #2
    Re: mysql errors

    "David Bruno" <webmaster@lowe stdomains.info> writes:
    [color=blue]
    > I've run a php script that uses mysql databases without problems
    > on one server, but then I changed web hosts and installed it the same
    > way buy I get a lot of errors which are all derived from the
    > script not being able to interact with the database.[/color]

    What are the errors? Saying "I get a lot of errors" doesn't give
    us much to analyze.
    [color=blue]
    > It finds the database and connects, but then can't do anything else.[/color]

    How do you know the connection is successful? Does the code do
    error checking? Is PHP configured to send errors to the browser?
    If not, are you looking in the web server's error logs? See what
    happens when you add the following lines to your script before
    connecting to the database:

    error_reporting (E_ALL);
    ini_set('displa y_errors', True);

    Errors can reveal Interesting Things to Bad Guys, so when you're
    finished debugging it's usually a good idea to set display_errors
    to False.
    [color=blue]
    > When it uses a database on a different server, things work fine,
    > so I'm guessing it's just a mysql error and not the fault of the script.[/color]

    Possibly. Have you verified that you have permission to connect
    to the database and that you have the necessary privileges once
    connected?
    [color=blue]
    > I'd appreciate any suggestions on how to deal with this.[/color]

    Please post the exact error messages and the code that caused them.
    That'll probably tell us what's wrong.

    --
    Michael Fuhr

    Comment

    • David Bruno

      #3
      Re: mysql errors

      > What are the errors? Saying "I get a lot of errors" doesn't give[color=blue]
      > us much to analyze.[/color]

      Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result
      resource in /home/webzero/public_html/skijumping/global.inc.php on line 35

      Warning: mysql_free_resu lt(): supplied argument is not a valid MySQL result
      resource in /home/webzero/public_html/skijumping/global.inc.php on line 36
      [color=blue]
      > How do you know the connection is successful? Does the code do
      > error checking? Is PHP configured to send errors to the browser?[/color]

      Errors appear in the browser. Script has as setup.php file which
      displays that is has connected to the database, but then
      can't write any tables to it.
      [color=blue]
      > Possibly. Have you verified that you have permission to connect
      > to the database and that you have the necessary privileges once
      > connected?[/color]
      I just have virtual hosting with cpanel 8.5. I create the database and
      that's it. The script does all the set-up. How can I verifty or change
      permissions.
      Everything is chmod as the installation instructions say.

      Thank you very much for your help.
      -David


      Comment

      • Michael Fuhr

        #4
        Re: mysql errors

        "David Bruno" <webmaster@lowe stdomains.info> writes:
        [color=blue][color=green]
        > > What are the errors? Saying "I get a lot of errors" doesn't give
        > > us much to analyze.[/color]
        >
        > Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result
        > resource in /home/webzero/public_html/skijumping/global.inc.php on line 35
        >
        > Warning: mysql_free_resu lt(): supplied argument is not a valid MySQL result
        > resource in /home/webzero/public_html/skijumping/global.inc.php on line 36[/color]

        It looks like mysql_query() is failing but the code isn't checking
        for that failure. Modify your code to look like this:

        $result = mysql_query($sq l)
        or die("mysql_quer y() failed: " . htmlentities(my sql_error()));

        For production you might want to handle the error more gracefully.

        The message from mysql_error() should tell you what's wrong. If
        you still can't figure out the problem, then please post some code
        so we can see exactly what you're doing.

        --
        Michael Fuhr

        Comment

        • Matthew Crouch

          #5
          Re: mysql errors

          "Michael Fuhr" <mfuhr@fuhr.org > wrote in message
          news:3fd2152d$1 _1@omega.dimens ional.com...[color=blue]
          > "David Bruno" <webmaster@lowe stdomains.info> writes:
          >[color=green][color=darkred]
          > > > What are the errors? Saying "I get a lot of errors" doesn't give
          > > > us much to analyze.[/color]
          > >
          > > Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL[/color][/color]
          result[color=blue][color=green]
          > > resource in /home/webzero/public_html/skijumping/global.inc.php on line[/color][/color]
          35[color=blue][color=green]
          > >
          > > Warning: mysql_free_resu lt(): supplied argument is not a valid MySQL[/color][/color]
          result[color=blue][color=green]
          > > resource in /home/webzero/public_html/skijumping/global.inc.php on line[/color][/color]
          36[color=blue]
          >
          > It looks like mysql_query() is failing but the code isn't checking
          > for that failure. Modify your code to look like this:
          >
          > $result = mysql_query($sq l)
          > or die("mysql_quer y() failed: " . htmlentities(my sql_error()));
          >[/color]
          Do what michael says here. Also:
          echo the query to screen right before you run it. Read it to see if it's
          right. Maybe copy it and paste it into phpmyadmin or whatever else you use
          to interact with the dB. Might yield more specific info


          Comment

          Working...