Current location: Hot Scripts Forums » Programming Languages » PHP » I have a short code that works on PHP 5 but not on PHP 4...please help!


I have a short code that works on PHP 5 but not on PHP 4...please help!

Reply
  #1 (permalink)  
Old 03-27-08, 12:16 AM
INTEL INTEL is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
I have a short code that works on PHP 5 but not on PHP 4...please help!

Hello,

Thank you for reading this thread. Here is my code:

PHP Code:

function apply_vote(){


    
$prosecc=$_GET['section'];
    
$item_id=$_GET['item_id'];
 
    try {

        switch (
$prosecc) {
            case 
'down':     
            
$vote = -1
            break;
            case 
'up':        
            
$vote 1
            break;
            
            default:        
            throw new 
Exception('Wrong Param!');
        }
        
        
$query "INSERT INTO
                `links_x_users`
            SET
                `vote` = '%d',
                `uid` = '%d',
                `lid` = '%d'
        "
;
    
        if (!@
dbquery(sprintf($query$voteget_uid(), $item_id)))
            throw new 
Exception('You already have voted for this item!');            
        
         
// Intended denormalization
         
        
$query="
            UPDATE 
                 me_users_links 
            SET  
                link_votes = link_votes + %d
            WHERE 
                link_id = %d
        "
;
    
    
dbquery(sprintf($query$vote$item_id));        
    
    } catch (
Exception $e) {
        die(
$e->getMessage());
    }
    
    
    
    if (isset(
$_GET['cat'])){
        
header("Location:../?task=links&section=".$_GET['cat']);     
        exit();
    }
    
header("Location:../?task=frontpage");


    

It works on PHP 5 but not PHP 4, if you could tell me how I can fix this, it would be very much appreciated.

Thank you in advance.
Reply With Quote
  #2 (permalink)  
Old 03-27-08, 12:26 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
First thing I notice: PHP4 doesn't handle exceptions.
__________________
The toxic ZCE
Reply With Quote
  #3 (permalink)  
Old 03-27-08, 02:18 AM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Why are you using PHP4 anyways?
Yep as Keith said... Exceptions dont work in PHP4
__________________
01010000 01001000 01010000
Reply With Quote
  #4 (permalink)  
Old 03-27-08, 10:14 AM
INTEL INTEL is offline
Newbie Coder
 
Join Date: Mar 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
because i wrote this code for someone and they are hosting with Yahoo which has PHP 4, i dont know how much of the code has to be re-written...i didnt think Yahoo would be so behind on technology (explains why they are beginning to suck on the market)..

thanks. i will try the exception thing.
Reply With Quote
  #5 (permalink)  
Old 03-27-08, 02:14 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Wow! I didnt know that the big Yahoo used PHP4! Dang...
__________________
01010000 01001000 01010000
Reply With Quote
  #6 (permalink)  
Old 03-27-08, 03:34 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Quote:
Originally Posted by phpdoctor View Post
Wow! I didnt know that the big Yahoo used PHP4! Dang...
HAHAHA... if you only knew.

Do not be so surprised. I work with Yahoo hosting all the time at the company for which I am employed. The last time we talked with them about it, they had no foreseeable plans of upgrading to PHP5. They have so many servers it'd no doubt be an extremely daunting undertaking.

It'd also end up breaking a LOT of currently utilized code.

There is a lot about Yahoo that would surprise you. Their Merchant Solutions hosting is basically Geocities.

They're also still using MySQL 3.

Think of used chewing gum, fishing line, scotch tape... now you're starting to get a good idea of what holds Yahoo's hosting together.
__________________
The toxic ZCE

Last edited by Keith; 03-27-08 at 03:40 PM.
Reply With Quote
  #7 (permalink)  
Old 03-27-08, 03:49 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Keith View Post
Think of used chewing gum, fishing line, scotch tape... now you're starting to get a good idea of what holds Yahoo's hosting together.
V Nice analogy
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #8 (permalink)  
Old 03-27-08, 03:59 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
hehe, didnt know that about Yahoo... I understand now, they have some much servers ect... that it would be crazy to convert everything...
__________________
01010000 01001000 01010000
Reply With Quote
  #9 (permalink)  
Old 03-28-08, 12:26 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
My hosting provided me with PHP4 of which I was annoyed at because all my scripts used PHP5 functions (or some of atleast) I had to go changing them all and reducing some of my website features!

I just found out a few days ago that they had PHP5 already to go... just needed to change something in the .htaccess! DOH!

Yahoo not got any options like that? (Does google not supply free hosting?)
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
  #10 (permalink)  
Old 03-28-08, 08:20 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Yahoo does not support PHP5, and they have disallowed use of .htaccess files. If you upload a .htaccess file to Yahoo it is ignored.

As far as I know, Google has googlepages.com, but there is no server side language support the last I'd checked. Everything is edited through a web interface.
__________________
The toxic ZCE
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP email code icbm Script Requests 1 07-03-07 09:35 PM
CGI Code Converting to PHP - need help PHP Warner PHP 4 03-29-06 07:32 AM
SMS (Shared Short Code / keyword) vagabondos Job Offers & Assistance 0 11-04-05 09:01 PM


All times are GMT -5. The time now is 07:39 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.