PHP - Detecting Fatal Errors Php<=5.1.6
I need to detect when a fatal error occurs in a shutdown function to ensure database records do no get hung up by a particular user when a coding modification goes south.
error_get_last() is not on the menu with my PHP version 5.1.6. Can anyone suggest an alternative? Thanks Similar TutorialsHey y'all. I've inherited a code base written in 5.6 that was at the time pretty bad and has since been abused pretty terribly; for instance, my predecessors decided to add '@'s to silence errors on mysql_* function calls instead of actually fixing things. However, there are no '@'s on the nested require statements that instantiate the same object multiple times inside other files. In production, this somehow works just fine - I get no errors displayed and no errors logged despite having error logging turned on in the php.ini and the fact that it's a freaking fatal error. However, in my docker setup I'm getting errors about declaring the same class twice, and I can't use the system enough to debug it. So I have a thought about how I can get around it locally in my docker container, but that solution can present problems when it comes to keeping track of actual changes versus changes for local development because this project has included every file in git - including the vendor and node_modules directories, as well as compiled files because ... well, reasons. So if I make changes locally to a file that shouldn't matter on the server, it will matter and will probably break things.
TL;DR - is it even possible to suppress fatal errors in PHP? If so, how?
Again, I feel the need to state that the only reason I'm asking is to debug the code I've inherited so I can fix it properly. Edited October 2, 2020 by maxxdI need a regular expression that detects a web address in a string of text. I need it to find any http://www or www. web address. Any domain (.co.uk, .com anything) All these would be picked up: http://domain.com http://www.domain.com www.domain.com http://domain.co.uk http://www.domain.co.uk www.domain.co.uk Also, it must pick up all folders and other url variables (www.site.com/page1?a=123 etc.) ** Also, most importantly:*** It must NOT pick up web addresses that are inside a <a href="">xxx</a> link already, only oes that are plain text and not embedded in this HTML. I have tried but it only does bits of the above. I can do the PHP code, just need to know the regular expression to drop into my preg_match_all code. Thanks in advance. I've made a small chicken names website, and I also have a chicken name list as a thread on a chicken related forum. People submit their names, and I manually add them to the list. With the names growing so much, I decided to make a small background system that lets me put in the current list names, then the new names submitted. It will then run the lists, compare them, and spit out/ignore any duplicates and generate the new list. But each time I use it, it doesn't get rid of the duplicates. Can anyone tell me why? if($_GET['list_updater'] || $_POST['list_updater']) { if(!$_POST['current_list'] || !$_POST['new_names']) { ?> <table> <form action="index.php" method="POST"> <input type="hidden" name="list_updater" value="1"> <tr> <td> <textarea name="current_list" cols="40" rows="20"></textarea> </td> </tr> <tr> <td> <textarea name="new_names" cols="40" rows="20"></textarea> </td> </tr> <tr> <td><input type="submit" value="Generate New List"></td> </tr> </form> </table> <?php } else { //start our counting numbers $x = 0; $s = 0; $a = 0; //make our arrays $check_to[0]; $new[0]; //get the values from our lists $old_list = explode("\n",$_POST['current_list']); $new_list = explode("\n",$_POST['new_names']); //get new list variables foreach($old_list as $value) { $check_to[$x] = $value; $x++; } //add all our new names foreach($new_list as $value) { for($s = 0; $s < count($new_list); $s++) { } } ?> <textarea cols="45" rows="20"> <?php for($t = 0; $t < count($new); $t++) { echo $new[$t]; } ?> </textarea> <?php } } How can i detect someone who is using proxy and has 2 or more accounts on my website?Or anyway, the important thing for me it is that they dont cheat because i have a competition and its forbidden to have 2 or more accounts.
I have a scenario where users are downloading files from a legacy system and uploading the files into a new system that I am supporting. Many of the files do not have an extension (most are tiffs).
The issue we have is that the new system doesn't know how to open these files (we have them open in a preview window in the new system). I have tried numerous solutions, including finfo_file() and the depreciated mime_content_type() funcitons), but all they seem to return is "application/octet-stream".
Thanks.
I have a php script that detects the user's mobile phone and browser and some other stuff. To display this info, I use: <?php echo htmlentities($_SERVER['HTTP_USER_AGENT']); ?> But this outputs a lot more than I need. It outputs the handset, the browser, the version etc... like this: Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53 Does anyone know what I need to change in the script just so I can have it display the handset name? All I want it to do is say something like "You have a Samsung Galaxy Note II" I have attached the mobile_detect script but I dont know what to edit because I don't really know php. Appreciate the help, JH Attached Files Mobile_Detect.php.zip 22.37KB 1 downloads Hi,
I`m currently generating spam via my own mailserver, its not much, but some of my clients receive messages that the messages they send could not be delivered. ( They are probably not snding them, but some script on one of the many websites is).
Problem is that i`m currently unable to figure out which one of the websites is generating this spam. There are about 150 websites on this server.
Some have old wordpress versions on them because the clients don`t ever update them.
I`ve looked into adding a line in php.ini which should log all mails.
mail.add_x_header = On mail.log="E:\logs\phpmail\php-mail-errors.log" However this file keeps on being 0 bytes . Also if i generate a mail via a contact form which i made but the log is not showing it. The mail gets picked up by the mail servers, so the script does work. I`ve also checked that the php version is 5.0 or higher because otherwise the lines i added to the php.in would not be accepted by a earlier version then 5.0. The last I`ve done is changed the rights to the log file to writetable for the iis user, perhaps thats whats needed for the lines inh php to work. Has anyone any experiende with this issue ? Hey guy, I really need your help with this. I have Input from a text area, in this format: a b c d e f g 12 34 435 124 What I need do to is to output only a certain line from every block of text, every block is divided by one or more empty lines. I have done this: $input = $_POST["input"]; $lines = explode("\r",$input); $num = count($lines); $line_to_extract = $_POST['line_to_extract']; for($i=0;$i<$num;$i++) { if($i == $line_to_extract) { echo 'Line '.$i.': '.$lines[$i].'<br />'; } } What I need to do is to detect the empty line so I can keep track of the line to extract. PLEASE HELP!!! I inherrited a site that has PHP code that decides to either serve the dedicated mobile site or desktop site to the user. I would prefer that tablets get served the mobile site. Currently Android tablet users get served the desktop site. I'd like to figure out how I can implement User Agent to detect an android tablet (with distinction from an Android phone) This is the code I'm working with to determine which site to serve (mobile or desktop) Thanks if ((strpos($user_agent, 'Mobile') === false && // Generic mobile browser string, most browsers have it. strpos($user_agent, 'SymbianOS') === false && // Nokia device running Symbian OS. strpos($user_agent, 'Opera M') === false && // Opera Mini or Opera Mobile. strpos($user_agent, 'Android') === false && // Android devices that don't have 'Mobile' in UA string. stripos($user_agent, 'HTC_') === false && // HTC devices that don't have 'Mobile' nor 'Android' in UA string. Case insensitive. strpos($user_agent, 'Fennec/') === false && // Firefox mobile strpos($user_agent, 'Kindle') === false && // Kindle Fire tablet strpos($user_agent, 'BlackBerry') === false) || // BlackBerry strpos($user_agent, 'iPad') === false) // iPad { // Serve Desktop Site return false; } How do I display the actual errors in IIS 7.5? If I miss a semicolon, I get: "HTTP Error 500.0 - Internal Server Error" absolutely useless. In prior versions, I could see the line and get to the PHP error. How do I display PHP errors? I've added: set_ini('display_errors', '1'); but it doesn't help. I have a string of mixed Japanese or Chinese and Western characters and I would really like to leave the western characters and remove the others. Is there any way to detect which UTF-8 characters are Japanese/Chinese and to remove them? I have tried to use this which I found on another thread but my version of PHP (5.3) will not allow the /u in the following Code: [Select] echo "<BR>".preg_replace('/[^\u4E00-\u9FFF]+/', '', $string); I have tried using various combinations of /p (these, plus others) Code: [Select] echo "<BR>".preg_replace('/\p{Bopomofo}+/u', '', $string); echo "<BR>".preg_replace('/\p{Hiragana}+/u', '', $string); and the /x{} option tells me the numbers are to large Code: [Select] echo "<BR>".preg_replace('/[^\x{4E00}-\x{9FFF}]+/', '', $string); My string for this example is this but any combination of western and Japanese/Chinese characters are possible in the title. 2011.12.06 19:00-20:00 / ふくいちライブカメラ (Live Fukushima Nuclear Plant Cam) | Uploaded: 06 Dec 2011 Thanks for any help. this code was working perfectly fine past few months. nothings changed and now i am getting this error: Quote Fatal error: Call to a member function value() on a non-object in /home/staceyxs/public_html/_includes/login.php on line 8 <table style="width: 100%" class="style17" background="../images/content.png"> <tr> <td class="style3" style="width: 266px"> <img alt="" src="../images/headers/VIPL.png" width="220" height="220" /></td> <td > <form action="../System/process.php" method="POST" style="height: 62px"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td><strong>Username:</strong></td><td><input class="txt" type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>" /></td><td><? echo $form->error("user"); ?></td></tr> <tr><td><strong>Password:</strong></td><td><input class="txt" type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>" /></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?> /> <font size="2">Remember me next time <input type="hidden" name="sublogin" value="1" /> <input type="submit" class="btn" value="Login" style="width: 70px; height: 40px" /></td></tr> <tr><td colspan="2" align="left"><br /><font size="2">[<a href="../System/forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br />Not registered? <a href="../Register/index.php"> Register Now!</a></td></tr> </table> [<a href="../System/help.php" onclick="window.open('../System/help.php','popup','width=480,height=230,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">Help</a>]</div> </form> </td> </tr> </table> hello, on a file upload, I get the error: Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 9920 bytes) in/home/content/38/8848538/html/dynamic-site/start-page/upload-page2.php on line 176 line 176 of my upload-page2.php is: $image=imagecreatefromjpeg($filepath); I dont really get whats going on. Ive set the max uplaod file size before this, which i changed to: $maxFileSize=9999999999999999999999; to make sure it wasn't this but it had no effect. i still get the fatal error. anyone got some ideas? i can post the whole php file if needed but may be a bit long winded I have a script which is uploading very large files into blobs (<=800MB). Now i had the max memory size in the php.ini set to 150MB and while uploading it would stop and tell me that that I exhausted all the bytes (157xxxxx can remember the exact figure but im pretty sure it equalled 150MB). Any ways I experimentally set the max memory size to 800MB just to see if that would help and now its telling me Fatal error: Out of memory (allocated 524288) (tried to allocate 804524032 bytes)? What is the meaning of this and how can one rectify the issue? Any info would be tremendous! -SB Hi guys, I have managed to get all my oAuth to work (basically), however the autorize.php is getting this error when "Allowing". Any ideas why? Only happens once I press allow and it should have redirected to the REDIRECT_URI. Thanks in advance. HOW TO FIX Fatal error: Uncaught Error: Using $this when not in object context in /testynarkotykowe/libs/timer/index.php:13 Stack trace: #0 /testynarkotykowe/index.php(36): TIMER::getTime('all') #1 /testynarkotykowe/m/pg/index.php(110): PAGE->PAGE(NULL, 'cart') #2 /testynarkotykowe/index.php(28): include_once('/testynarkotyko...') #3 /testynarkotykowe/index.php(115): loadMod('pg') #4 {main} thrown in /testynarkotykowe/libs/timer/index.php on line 13 HOW TO TRACK THE ERROR? http://testynarkotykowe.j13x.pl/index.txt Quote<?php #error_reporting(0); define('PHP','.php'); require_once('_gz/php_speedy'.PHP); define('INX','index'); define('HTML','.html'); error_reporting(E_ALL ^ E_NOTICE); define('N','/'); ini_set('memory_limit','512M'); define('DIR_LIB','libs/'); define('DIR_MOD','m/'); define('DIR_TPL','tpl/'); define('DIR_LNG','lng/'); define('R_TIME',2*1000); define('PTH',''); define('HTTP','http://'); define('RANGE_IMG',5000); define('URL',HTTP.$_SERVER['HTTP_HOST'].N.PTH); define('_URL',HTTP.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); define('TAX_RATE',0.08); /* for drug_tests [!] */ define('DOTPAY_ID',37953); define('POPUP_NW',"'mywindow','width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes')"); define('_E','ENGINE | '); define('_LNG','X lng file in mod'); define('_DB','DB | '); define('H','Hacking Attempt | '); define('_C','COOKIE | '); define('_S','SESSION | '); define('NOREPLY','noreply'); define('WWW','www.'); define('JQ','jquery'); define('SEP',' | '); define('SP','|'); define('URI_SEP',','); define('BULK_URI','?bulk'); define('GUEST','Anonymous'); define('C_EXP',time()+24*3600*30); define('PP',14); define('TH_W',125); define('TH_H',75); define('TH',95); define('COUNTDOWN',7); define('HIDE','st'); define('NL',"\n"); define('DATETIME',date('Y-m-d H:i:s')); define('DATETIME_YESTERDAY',date("Y-m-d",time()-(60*60*24))); define('IMG_W',864); define('IMG_H',720); define('IMG_',70); define('IMG_TH','_th.'); define('IMG_AV','_avatar.'); define('MAIL_STYLE',' style="color:blue;text-decoration:underline"'); define('A4_W',946); define('A4_H',1334); /* 595,842 */ define('LIMIT_SIGNATURE',30); define('LIMIT_UTOPICS',16); define('HASH','#'); define('C_TIP_LIMIT',10); define('C_LIMIT',2);/*COMMENTS*/ define('WRAP0',42); define('WRAP1',370);/*74 x 5*/ define('LIMIT_PREFACE',300); define('hideAFTER',3000); define('ERASE_AFTER_X_DAYS',30); define('NOTIFS_LIMIT',2000); define('__ID','ID non'); define('__D','!digit'); define('__R','record non'); define('LOC','Location: '); define('PER_PG',10); define('PER_PG2',5); define('PER_PG3',25); define('PER_PG4',40); session_start(); define('DATETIME_NO','0000-00-00 00:00:00'); define('AminLENGTH',10); define('fade1',100); define('RANGE',50000); define('TH_PRE','th.'); define('TH_EXT','jpg'); define('USERNAME','0100000');/*OBLIGATORY: "0" on the beginning*/ define('USERNAME_LENGTH',strlen(USERNAME)); define('QMIN_LENGTH',10); define('BALANCE0',"0.00"); define('PIN_ATTEMPTS',5); define('MIN_AMOUNT',100); define('RATE0','0.0000'); function datetime($diff) { $timestamp=time(); $tm=86400*$diff; $tm=$timestamp+$tm; return $tm; } define('DATETIME1',date('Y-m-d H:i:s',datetime(1))); define('LANGUAGE','pl'); define('LNG',LANGUAGE.N); define('LG','_'.LANGUAGE); define('MIN_LENGTH',3); define('CURRENCY','PLN'); /* testy */ define('_DEFAULT_ITEM_CNT',4); define('_PROMO_ITEM_CNT',11); define('_PROMO_'.strtoupper(LANGUAGE).'_PRICE',115); define('_PROMO_'.strtoupper(LANGUAGE).'_BEFORE_PRICE',129); /*define('U_FIELDS','id,p,phone,mail,act_lnk,session,name');*/ define('URL_LENGTH',120); /* to 120 */ define('AUTOSAVE_DRAFT_TIME',60*1000); /* TESTY */ #if(!empty($_GET['uid'])) { if(ctype_digit($_GET['uid'])) { $_SESSION['ref'] = $_GET['uid']; unset($_SESSION['uid']); } header(LOC.URL); exit; }/* or $_SERVER['HTTP_HOST'] == 'www.testynarkotykowe.pl'*/ function loadLib($l) { $pth = DIR_LIB.strtolower($l).N.basename(INX).PHP; if(file_exists($pth)) include_once($pth); else die(_E.'loadLib [ '.$pth.' ]'); } function loadLang($l,$m) { $pth = DIR_LNG.strtolower($l).N.strtolower($m).N.basename(INX).PHP; if(file_exists($pth)) include_once($pth); else die(_E.'loadLang [ '.$pth.' ]'); } loadLib('url'); @URL::sUrl(); #try { $db = new PDO('mysql:host=localhost;dbname=andypsv_cocain','root','',array(PDO::ATTR_PERSISTENT=>true)); } catch(PDOException $e) { die('PDO::Can\'t connect'); } try { $db = new PDO('mysql:host=serwer2056122.home.pl;dbname=32538868_thejokerred','32538868_thejokerred','M98thiuhsnduit@@##^',array(PDO::ATTR_PERSISTENT=>true)); } catch(PDOException $e) { die('PDO::Can\'t connect'); } $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); define('PRFX','drugtests_'); $db->query('SET NAMES utf8'); $db->query('SET CHARACTER SET utf8'); $db->query('SET collation_connection = utf8_general_ci'); header('content-type:text/html;charset:utf-8'); $c = $db->query('SELECT * FROM '.PRFX.'cfg'.LG); if($c->rowCount() == 0) die(_E.'X cfg file'); $c = $c->fetch(); foreach($c as $k=>$v) define('PG_'.strtoupper($k),$v); define('PG_TPL',DIR_TPL.PG_TPLX.DIR_MOD); define('C_NAME',PG_T2); loadLib('ip'); loadLib('auth'); loadLib('pages'); loadLib('func'); loadLib('time'); function uQuery($GET) { if(substr($GET,0,USERNAME_LENGTH) == USERNAME) $sql = 'id = "'.substr($GET,USERNAME_LENGTH).'"'; else $sql = 'uri = "'.$GET.'"'; return $sql; } function rtrnLoc() { $LENGTH = strlen(URL); if($_SERVER['HTTP_REFERER'] == URL) return URL; else if(substr($_SERVER['HTTP_REFERER'],0,$LENGTH) == URL) return $_SERVER['HTTP_REFERER']; else return URL; } function arr_short($arr) { $res = array(); foreach($arr as $subArray) foreach($subArray as $k => $v) $res [$k] = $v; return $res; } function loadMod($m) { $pth = DIR_MOD.strtolower($m).N.INX.PHP; if(file_exists($pth)) include_once($pth); else exit(header(LOC.URL,true,301)); } function errLog($err) { global $db; $q = $db->query('INSERT INTO '.PRFX.'err (date,err) VALUES ("'.DATETIME.'","'.$err.'")'); if($q->rowCount() <> 1) die(H.'errLog, fatal failure [not logged error to db]'); else return substr(strstr($err,':'),2); } class PAGE { var $_t,$_k,$_d,$_c,$_nav,$_,$tpl,$u,$md; function PAGE($md='',$md2='',$md3='',$md4='') { global $db,$md; loadLib('timer'); @TIMER::setTimer('all'); require_once(DIR_LIB.DIR_TPL.'class.template'.PHP); $this->tpl = new Template_Lite; $_gTime = TIMER::getTime('all'); $this->tpl->assign('_gTime',$_gTime); $this->tpl->assign('URL',URL); define('TPL',URL.DIR_TPL.PG_TPLX); $this->tpl->assign('TPLx',DIR_TPL.PG_TPLX); $CONSTANS = get_defined_constants(); foreach($CONSTANS as $k => $v) $this->tpl->assign($k,$v); foreach($_POST as $k => $v) if(is_array($_POST[$k])) foreach($_POST[$k] as $k2 => $v2) $_POST[$k][$k2] = htmlspecialchars(trim($v2)); else $_POST[$k] = htmlspecialchars(trim($v)); foreach($_COOKIE as $k => $v) $_COOKIE[$k] = htmlspecialchars(trim($v)); $this->tpl->assign('_GET',$_GET); $this->tpl->assign('_POST',$_POST); $this->tpl->assign('_COOKIE',$_COOKIE); $this->tpl->assign('_SESSION',$_SESSION); $this->tpl->assign('INX',INX); $this->u = isUlogd(str_replace(' ','',PG_T2)); $this->tpl->assign('u',$this->u); $pth = DIR_LNG.LNG.INX.N.INX.PHP; if(file_exists($pth)) { include_once($pth); $lng_index = $_; } else die(_LNG.' [[ index ]]'); $md = strtolower($md.N); $pth = DIR_LNG.LNG.$md.INX.PHP; $this->md = $md; $this->tpl->assign('md',substr($md,0,-1)); if(file_exists($pth)) include_once($pth);/* else die(_LNG);*/ $LNG_all = array_merge($lng_index,$_); $_ = ''; /* HERE IS ISSUE WHEN A FILE IS __INCLUDED <br/> unnecessary, temp-fix: LNG_attached */ if(!empty($md2)) { $md2 = strtolower($md2.N); $pth = DIR_LNG.LNG.$md2.INX.PHP; if(file_exists($pth)) include_once($pth); else die(_LNG.'2: '.$pth); $md2_index = $_; $LNG_all = array_merge($LNG_all,$md2_index); } if(!empty($md3)) { $md3 = strtolower($md3.N); $pth = DIR_LNG.LNG.$md3.INX.PHP; if(file_exists($pth)) include_once($pth); else die(_LNG.'3: '.$pth); $md3_index = $_; $LNG_all = array_merge($LNG_all,$md3_index); } if(!empty($md4)) { $md4 = strtolower($md4.N); $pth = DIR_LNG.LNG.$md4.INX.PHP; if(file_exists($pth)) include_once($pth); else die(_LNG.'4: '.$pth); $md4_index = $_; $LNG_all = array_merge($LNG_all,$md4_index); } $this->_ = $LNG_all; $this->tpl->assign('_',$this->_); $this->tpl->assign('LG',substr(LG,1)); //? $this->tpl->assign('i_drugtests','drug_tests/'); if(ctype_digit(end(explode(',',$_GET[0])))) $this->tpl->assign('col2',1); $q = $db->query('SELECT * FROM '.PRFX.'c0'.LG); if($q->rowCount() == 0) die(_E.'no categories'); while($_c0 = $q->fetch()) $c0[] = $_c0; $this->tpl->assign('c0',$c0); #var_export($_SESSION); die; #session_destroy(); /* CART */ $q = $db->query('SELECT * FROM `'.PRFX.'products'.LG.'`'); if($q->rowCount() == 0) die(_DB.'no records'); while($cart = $q->fetch()) { $cart['t_url'] = _url($cart['t']); $cart['base'] = sprintf('%.2f',$cart['base']); $cart['unit_'] = preg_replace('#[0-9]+\.+[0-9]#i','',$cart['unit']); if(empty($cart['total'])) $cart['total'] = sprintf('%.2f','0'); $cart['t__'] = ucfirst($cart['t_']); $cart['illegal'] = str_replace("\n",'<br />',$cart['illegal']); if(isset($_SESSION['_'.$cart['t_']])) { $cart['amount'] = $_SESSION['_'.$cart['t_']]; // if($cart['unit'] == '0.1g') $cart['amount'] *= 10; $cart['total'] = sprintf('%.2f',$cart['base']*$cart['amount']); $cart['price_table'] = explode(NL,$cart['prices']); #$cart['discount'] = $cart['total']-(CART::getPrice($cart['price_table'],$cart['amount'])/($tax_rate+1)); if(substr($cart['discount'],0,1) == '-') $cart['discount'] = substr($cart['discount'],1); if($cart['unit'] == '0.1g') $cart['amount'] /= 10; } $_cart[] = $cart; } $this->tpl->assign('cart',$_cart); $this->tpl->assign('items_in_cart',array_sum_key($_cart,'amount')); $this->tpl->assign('cart_total',sprintf('%.2f',array_sum_key($_cart,'total'))); $q = $db->query('SELECT * FROM '.PRFX.'promotion WHERE ip = "'.getClientIp().'" LIMIT 1'); if($q->rowCount() == 0) { $db->exec('INSERT INTO '.PRFX.'promotion (ip,time,u) VALUES ("'.getClientIp().'","'.date('m/d/Y h:i A',strtotime(date('m/d/Y h:i A').' + 2 hours 56 minutes')).'","'.$this->u['nick'].'")'); $this->tpl->assign('countdownTime',date('m/d/Y h:i A',strtotime(date('m/d/Y h:i A').' + 2 hours 56 minutes'))); } else { $countdownTime = $q->fetch(); $this->tpl->assign('countdownTime',$countdownTime['time']); } } function run() { global $db; $_ON_LOGGED = $db->query('SELECT COUNT(*) FROM `'.PRFX.'u` WHERE session >= '.(time()-300)); $this->tpl->assign('_ON_LOGGED',$_ON_LOGGED->rowCount()); if(!empty($this->u['id'])) $db->exec('UPDATE `'.PRFX.'u` SET session = "'.time().'" WHERE id = "'.$this->u['id'].'" LIMIT 1'); else $this->u['nick'] = ''; $db->exec('DELETE FROM `'.PRFX.'u_on` WHERE DATE_ADD(time,INTERVAL 3 HOUR) < NOW()'); $q = $db->query('SELECT u FROM `'.PRFX.'u_on` WHERE ip = "'.getClientIp().'" LIMIT 1'); if($q->rowCount() == 1) $db->exec('UPDATE `'.PRFX.'u_on` SET time = NOW(),u = "'.$this->u['nick'].'" WHERE ip = "'.getClientIp().'" LIMIT 1'); else $db->exec('INSERT INTO `'.PRFX.'u_on` VALUES ("'.getClientIp().'",NOW(),"'.$this->u['nick'].'")'); $rlt = $db->query('SELECT COUNT(ip) FROM `'.PRFX.'u_on`'); $this->tpl->assign('_ON',$rlt->rowCount()); /* if(!empty($this->u['id'])) { $q = q('SELECT COUNT(*) AS total FROM (SELECT * FROM '.PRFX.'messages WHERE _to = "'.$this->u['id'].'" AND `read` = "0" GROUP BY _from ORDER BY id DESC) x ORDER BY id DESC LIMIT 1'); $cnt = f($q); $this->tpl->assign('new_messages',$cnt['total']); $q = q('SELECT COUNT(*) as total FROM '.PRFX.'notifications WHERE u_to = "'.$this->u['id'].'" AND `read` = "0" LIMIT 1'); $cnt = f($q); $this->tpl->assign('new_notifs',$cnt['total']); }*/ if(empty($this->_k)) $this->_k = PG_KEYWORDS; if(empty($this->_d)) $this->_d = PG_DESCRIPTION; if(empty($_GET[0])) $t = PG_T_MAIN; else if(empty($this->_t)) $t = ucfirst(PG_T_MAIN); else $t = $this->_t; #.SEP.PG_T; $this->tpl->assign('_t',$t); $this->tpl->assign('_k',$this->_k); $this->tpl->assign('_d',$this->_d); $this->tpl->assign('_nav',$this->_nav); $this->tpl->assign('_c',$this->_c); $this->tpl->display(DIR_TPL.N.PG_TPLX.INX.HTML); } #### function mbl($st=true,$redir=true,$loc='') { #if($this->u['ban'] == 1) die('Account Blocked (BAN)'); foreach($_GET as $k => $v) $uri .= $v.'/'; if($_SERVER['REQUEST_URI'] <> '/login') { if(empty($loc)) $loc = substr(str_replace('|login|','',$uri),0,-1); if(!empty($this->u['id']) AND $_GET[0] == 'login') exit(header(LOC.URL)); if(!$st) { if($this->u['id']) if($redir) exit(header(LOC.URL.$loc)); else return false; } else { if(!$this->u['id']) if($redir) exit(header(LOC.URL.'login'.N.$loc)); else return false; } } } } if(empty($_GET[0]) OR substr($_GET[0],0,1) == '?') loadMod(PG_H_MOD); elseif(is_dir(DIR_MOD.$_GET[0])) loadMod($_GET[0]); else { loadMod(PG_H_MOD); // die(H.'no mod'); } $compressor->finish(); ?>
Hello, I am trying to run a script on my site , The script is this : https://github.com/simplecoin/simplecoin and I am getting these errors [Sat Aug 13 11:47:01 2011] [error] [client 84.228.254.88 ] PHP Fatal error: Call to a member function fetch() on a non-object in /var/www/includes/stats.php on line 42,[/code] Code: [Select] ] PHP Warning: Invalid argument supplied for foreach() in /var/www/includes/stats.php on line 89 and Code: [Select] ] PHP Warning: Invalid argument supplied for foreach() in /var/www/stats.php on line 75 I run ubuntu 11 vps . Some one told me that [quote]Probably this query is not returning a value, so it gives an error. [code]$sql = "SELECT count(id) FROM shares WHERE id > $lastwinningshare AND our_result='N'";Most likely it will go away as soon as it returns something. [/quote] from the file /includes/stats.php I really need to fix this problem , is there any module i need to install or the code is incorrect ? If you want i can give you a link to php info of my vps . Thanks a lot for the help ! Hi guys and girls, I am trying to create an XML document from an php document and a sql_query but I am getting this fatal error: Fatal error: Call to undefined method DOMComment::createElement() in /content_ro/webdev/htdocs/schools/hhs/psy_bookings/home.php on line 15 <?php include("php/dbconnect.php"); //connects to the database $table_id = 'booking'; $query = "SELECT * FROM $table_id WHERE (booking.bookingDate = curDate()) AND roomID = 1 ORDER BY startTime"; $room1 = mysql_query($query); //create a new DOM document $doc = new DOMComment('1.0'); //create root element $root = $doc->createElement('root'); $root = $doc->appendChild($root); //process one row at at time while($row = mysql_fetch_assoc($room1)){ //add node for each row $occ = $doc->createElement($table_id); $occ = $doc->appendChild($occ); //add achild for each field foreach ($row as $fieldname => $fieldvalue){ $child = $doc->createElement($fieldname); $child = $occ->appendChild($child); $value = $doc->createTextNode($fieldvalue); $value = $child->appendChild($value); } } mysql_free_result($room1); $xml_string = $doc->saveXML(); echo $xml_string; ?> I am following a tutorial on http://www.tonymarston.net/php-mysql/dom.html Hi, I'm getting below error in my page http://www.cidirealty.com/NWMLS/mls.php PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in E:\USERS\cidirealty\www\NWMLS\mls.php:54 Stack trace: #0 E:\USERS\cidirealty\www\NWMLS\mls.php(54): SimpleXMLElement->__construct(' Does anyone know what this means and how to solve this? Thank you. |