shage Posted June 6, 2007 Share Posted June 6, 2007 Im new and thank you for the welcomes! Why am i getting such errors? Thank you in advance, im new to this whole php thing so take it easy on me ya know function version_compare_replacement_sub( $version1, $version2, $operator = "" ) { global $versiontype_lookup; if ( isset( $versiontype_lookup ) ) { $versiontype_lookup['dev'] = 10001; $versiontype_lookup['a'] = 10002; $versiontype_lookup['alpha'] = 10002; $versiontype_lookup['b'] = 10003; $versiontype_lookup['beta'] = 10003; $versiontype_lookup['RC'] = 10004; $versiontype_lookup['pl'] = 10005; } if ( isset( $Var_1 ) ) { $version1 = $versiontype_lookup[$version1]; } if ( isset( $Var_1 ) ) { $version2 = $versiontype_lookup[$version2]; } case "<" : case "lt" : default : return intval( $version1 < $version2 ); case "<=" : case "le" : default : return intval( $version1 <= $version2 ); case ">" : case "gt" : default : return intval( $version2 < $version1 ); case ">=" : case "ge" : default : return intval( $version2 <= $version1 ); case "==" : case "=" : case "eq" : default : default : return intval( $version1 == $version2 ); case "!=" : case "<>" : case "ne" : default : default : return intval( $version1 != $version2 ); default : if ( $version1 == $version2 ) { return 0; } else if ( $version1 < $version2 ) { return -1; } return 1; } Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/ Share on other sites More sharing options...
trq Posted June 6, 2007 Share Posted June 6, 2007 Why am i getting such errors? Such as what? Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269252 Share on other sites More sharing options...
shage Posted June 6, 2007 Author Share Posted June 6, 2007 Parsing Error: line 152 - parse error, unexpected T_CASE my friend wrote me a small script and it works until it calls that function Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269255 Share on other sites More sharing options...
trq Posted June 6, 2007 Share Posted June 6, 2007 I dont see any parse errors, but looking at it. That function makes no sense. You can not (should not) have more then one default option defined in a switch. Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269256 Share on other sites More sharing options...
shage Posted June 6, 2007 Author Share Posted June 6, 2007 so i could just take that function out and all references to it and it would be alright again i knwo nothing of php Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269257 Share on other sites More sharing options...
taith Posted June 6, 2007 Share Posted June 6, 2007 also... your missing you entire switch() function... Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269258 Share on other sites More sharing options...
shage Posted June 6, 2007 Author Share Posted June 6, 2007 might be why its not working, hmmmm Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269259 Share on other sites More sharing options...
trq Posted June 6, 2007 Share Posted June 6, 2007 also... your missing you entire switch() function... Hehe... I must be going blind. so i could just take that function out and all references to it and it would be alright again Maybe, that function is broken, but you may also have other code that relies on it (when its working). Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269262 Share on other sites More sharing options...
shage Posted June 6, 2007 Author Share Posted June 6, 2007 Well i took it out and it errors on function imagecreatefunction( $x_size, $y_size ) { $ImageCreateFunction = "ImageCreate"; if ( 0 <= phpthumb_functions::gd_version( ) ) { $ImageCreateFunction = "ImageCreateTrueColor"; } do { if ( function_exists( $ImageCreateFunction ) ) break; return phpthumb::ErrorImage( $ImageCreateFunction."() does not exist - no GD support?" ); } while( 0 ); if ( $x_size <= 0 || $y_size <= 0 ) { return phpthumb::ErrorImage( "Invalid image dimensions: ".$ImageCreateFunction."(".$x_size.", ".$y_size.")" ); } else { } return ( $x_size, $y_size ); } that was because it was erroring before that call,hmm Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269264 Share on other sites More sharing options...
taith Posted June 6, 2007 Share Posted June 6, 2007 return doesnt understand a , in that way... you'd need to use a . to combine strings... Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269268 Share on other sites More sharing options...
per1os Posted June 6, 2007 Share Posted June 6, 2007 <?php function version_compare_replacement_sub( $version1, $version2, $operator = "" ) { global $versiontype_lookup; if ( isset( $versiontype_lookup ) ) { $versiontype_lookup['dev'] = 10001; $versiontype_lookup['a'] = 10002; $versiontype_lookup['alpha'] = 10002; $versiontype_lookup['b'] = 10003; $versiontype_lookup['beta'] = 10003; $versiontype_lookup['RC'] = 10004; $versiontype_lookup['pl'] = 10005; } if ( isset( $Var_1 ) ) { $version1 = $versiontype_lookup[$version1]; } if ( isset( $Var_1 ) ) { $version2 = $versiontype_lookup[$version2]; } switch ($operator) { case "<" : case "lt" : return intval( $version1 < $version2 ); break; case "<=" : case "le" : return intval( $version1 <= $version2 ); break; case ">" : case "gt" : return intval( $version2 < $version1 ); break; case ">=" : case "ge" : return intval( $version2 <= $version1 ); break; case "==" : case "=" : case "eq" : return intval( $version1 == $version2 ); break; case "!=" : case "<>" : case "ne" : default: return intval( $version1 != $version2 ); break; } if ( $version1 == $version2 ) { return 0; } else if ( $version1 < $version2 ) { return -1; } return 1; } ?> Given I didn't mess up syntax that should work. Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269271 Share on other sites More sharing options...
shage Posted June 6, 2007 Author Share Posted June 6, 2007 function version_compare_replacement_sub($version1, $version2, $operator='') { static $versiontype_lookup = array(); if (empty($versiontype_lookup)) { $versiontype_lookup['dev'] = 10001; $versiontype_lookup['a'] = 10002; $versiontype_lookup['alpha'] = 10002; $versiontype_lookup['b'] = 10003; $versiontype_lookup['beta'] = 10003; $versiontype_lookup['RC'] = 10004; $versiontype_lookup['pl'] = 10005; } if (isset($versiontype_lookup[$version1])) { $version1 = $versiontype_lookup[$version1]; } if (isset($versiontype_lookup[$version2])) { $version2 = $versiontype_lookup[$version2]; } switch ($operator) { case '<': case 'lt': return intval($version1 < $version2); break; case '<=': case 'le': return intval($version1 <= $version2); break; case '>': case 'gt': return intval($version1 > $version2); break; case '>=': case 'ge': return intval($version1 >= $version2); break; case '==': case '=': case 'eq': return intval($version1 == $version2); break; case '!=': case '<>': case 'ne': return intval($version1 != $version2); break; } if ($version1 == $version2) { return 0; } elseif ($version1 < $version2) { return -1; } return 1; } That fixed it dont know why but it diid Link to comment https://forums.phpfreaks.com/topic/54444-solved-im-new/#findComment-269273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.