PHP 4 to PHP 5 woes

Discussion in 'PHP' started by BRUm, Oct 27, 2006.

  1. #1
    Hi,

    You may have, or may not have seen my PPC site: www. cpcads .net

    I had it on one host, which had PHP4, it worked fine, until the scammer ran off with the server. So now, I'm on a new host .. I transferred all the .php files and got my MySQL server back up.

    I'm on it, racking my brains why the heck am I getting these errors:

    
    
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /disk2/brum/public_html/ads/register.php on line 96
    
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /disk2/brum/public_html/ads/register.php on line 98
    
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /disk2/brum/public_html/ads/register.php on line 111
    
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /disk2/brum/public_html/ads/register.php on line 124
    
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /disk2/brum/public_html/ads/register.php on line 126
    No database selected
    
    Code (markup):
    I didn't get them on my other host ... hmmm .. So I go into the Cpanel and I see..
    Noooooooooooooooooooooooo! Does this mean I'll have to rewrite my entire code that took me months? :(

    Help is greatly appreciated.

    Thanks,

    Lee.
     
    BRUm, Oct 27, 2006 IP
  2. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hmm... you have to post more than just the error messages for people to tell you what went wrong...

    but i would think that the major suspect is the use of post or get variables without the use of $_POST and $_GET

    make sure that all variables posted to the page are called by using $_POST and variables paged through the url are called by using $_GET

    or post more details...
     
    daboss, Oct 27, 2006 IP
    BRUm likes this.
  3. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This is sort of stating the obvious but I assume you have checked that the login details for your database have been updated for the new host.

    Other potential issues might be some mysqli / mysql incompatibility but I doubt it.
     
    streety, Oct 27, 2006 IP
    BRUm likes this.
  4. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #4
    Thanks for your input guys. I've never used $_GET in my coding, I always use $_POST so I'll look into that.

    Streety, yeah I have checked that, but only afterwards :D
     
    BRUm, Oct 27, 2006 IP
  5. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Php 4 to 5 migration is usually no problem and we had to rewrite (change a bit) only one script on our server. I don't think this is a php5 issue but you should post some code. No database selected means that the db name has changed when you switched hosts (cpcads_db to cpcad_db for example).
     
    maiahost, Oct 27, 2006 IP
    BRUm likes this.
  6. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #6
    My host has php4 but since php5 runs like cgi script they say that there is a way to enable the php5 support, even when it takes considerable more resources.

    php5 can be enable via .htaccess thought according their directions.

    I suppose there must be something similar to switch back to php4 when 5 is already enabled.

    When running your own linux server, there is indeed a batch command to do so.
     
    Pat Gael, Oct 28, 2006 IP
    BRUm likes this.
  7. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Hi BRUm....

    This is what I think about your code.

    Problem.
    Your code trying to read a number of row from empty resource or empty variable that's why this error happening.

    Solution.
    Check your database connection and your database name...make sure your database is exist....and connect successfully

    Also before you use the mysql_num_rows() ...first check the resources if it's empty or not.

    example

    $resource = mysql_query($query);
    if(empty($resource)){
    //if the resource is empty..don't run mysql_num_rows()
    }else{
    //if is not empty ...then run mysql_num_rows()
    }
     
    php-lover, Oct 28, 2006 IP
    BRUm likes this.
  8. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #8
    Thanks a lot guys. I'll check all of this today :) Rep'd.
     
    BRUm, Oct 28, 2006 IP