April 27, 201214 yr My profile page is giving me the following errors. Deprecated: Function eregi() is deprecated in /home/******/public_html/root/res.php on line 185 Notice: Undefined index: device in /home/******/public_html/root/res.php on line 247 LINES 185 & 247 are marked below. Using PHP 5.3.x On line 185, I've tried preg and preg_match. They both gave me errors. I appreciate any help and please don't answer with to complicated replies. I'm only a rookie and as you can see this is all I could achieve. Thanks, Scott // ------- DETECT USER DEVICE ---------- $user_device = ""; $agent = $_SERVER['HTTP_USER_AGENT']; if (preg_match("/iPhone/", $agent)) { $user_device = "iPhone Mobile"; } else if (preg_match("/Android/", $agent)) { $user_device = "Android Mobile"; } else if (preg_match("/IEMobile/", $agent)) { $user_device = "Windows Mobile"; } else if (preg_match("/Chrome/", $agent)) { $user_device = "Google Chrome"; } else if (preg_match("/MSIE/", $agent)) { $user_device = "Internet Explorer"; } else if (preg_match("/Firefox/", $agent)) { $user_device = "Firefox"; } else if (preg_match("/Safari/", $agent)) { $user_device = "Safari"; } else if (preg_match("/Opera/", $agent)) { $user_device = "Opera"; } $OSList = array ( // Match user agent string with operating systems 'Windows 3.11' => 'Win16', 'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', 'Windows 98' => '(Windows 98)|(Win98)', 'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)', 'Windows XP' => '(Windows NT 5.1)|(Windows XP)', 'Windows Server 2003' => '(Windows NT 5.2)', 'Windows Vista' => '(Windows NT 6.0)', 'Windows 7' => '(Windows NT 6.1)|(Windows NT 7.0)', 'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)', 'Windows ME' => 'Windows ME', 'Open BSD' => 'OpenBSD', 'Sun OS' => 'SunOS', 'Linux' => '(Linux)|(X11)', 'Mac OS' => '(Mac_PowerPC)|(Macintosh)', 'QNX' => 'QNX', 'BeOS' => 'BeOS', 'OS/2' => 'OS/2', 'Mac OS' => 'Mac OS', 'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)' ); // Loop through the array of user agents and matching operating systems foreach($OSList as $CurrOS=>$Match) { // Find a match LINE 185: if (eregi($Match, $agent)) { break; } else { $CurrOS = "Unknown OS"; } } $device = "$user_device : $CurrOS"; // ------- END DETECT USER DEVICE ---------- // ------- POST NEW BLAB TO DATABASE --------- $anno_outout_msg = ""; if (isset($_POST['anno_field']) && $_POST['anno_field'] != "" && $_POST['anno_field'] != " "){ $annoWipit = $_POST['annoWipit']; $sessWipit = base64_decode($_SESSION['wipit']); if (!isset($_SESSION['wipit'])) { } else if ($annoWipit == $sessWipit) { // Delete any annos over 50 for this member $sqlDeleteAnnos = mysql_query("SELECT * FROM announcing WHERE tkt_id='$id' ORDER BY anno_date DESC LIMIT 50"); $bi = 1; while ($row = mysql_fetch_array($sqlDeleteAnnos)) { $anno_id = $row["id"]; if ($bi > 20) { $deleteAnnos = mysql_query("DELETE FROM announcing WHERE id='$anno_id'"); } $bi++; } // End Delete any annos over 20 for this member $anno_field = $_POST['anno_field']; $anno_field = stripslashes($anno_field); $anno_field = strip_tags($anno_field); $anno_field = mysql_real_escape_string($anno_field); $anno_field = str_replace("'", "'", $anno_field); $sql = mysql_query("INSERT INTO announcing (tkt_id, the_anno, anno_date, anno_type, anno_device) VALUES('$id','$anno_field', now(),'a','$anno_device')") or die (mysql_error()); $anno_outout_msg = "Your announcement has been posted!"; } } // ------- END POST NEW BLAB TO DATABASE --------- // ------- MEMBER BLABS OUTPUT CONSTRUCTION --------- /////// Mechanism to Display Pic if (file_exists($check_pic)) { $anno_pic = '<div style="overflow:hidden; height:40px;"><a href="res.php?id=' . $id . '"><img src="' . $check_pic . '" width="40px" border="0" /></a></div>'; } else { $anno_pic = '<div style="overflow:hidden; height:40px;"><a href="res.php?id=' . $id . '"><img src="' . $default_pic . '" width="40px" border="0" /></a></div>'; } /////// END Mechanism to Display Pic $sql_annos = mysql_query("SELECT id, tkt_id, the_anno, anno_date, anno_type, anno_device FROM announcing WHERE tkt_id='$id' ORDER BY anno_date DESC LIMIT 30"); while($row = mysql_fetch_array($sql_annos)){ $annoid = $row["id"]; $announcer_id = $row["tkt_id"]; $the_anno = $row["the_anno"]; $the_anno = ($activeLinkObject -> makeActiveLink($the_anno)); $anno_date = $row["anno_date"]; $convertedTime = ($myObject -> convert_datetime($anno_date)); $whenAnno = ($myObject -> makeAgo($convertedTime)); $anno_date = $row["anno_date"]; $anno_type = $row["anno_type"]; LINE 247: $anno_device = $row["device"]; $announcerDisplayList .= ' <table style="background-color:#FFF; border:#999 1px solid; border-top:none;" cellpadding="5" width="100%"> <tr> <td width="10%" valign="top">' . $anno_pic . '</td> <td width="90%" valign="top" style="line-height:1.5em;"> <span class="liteGreyColor textsize9">' . $whenAnno . ' <a href="res.php?id=' . $announcer_id . '"><strong>' . $mainNameLine . '</strong></a> via <em>' . $anno_device . '</em></span><br /> ' . $the_anno . ' </td> </tr></table>'; }
April 27, 201214 yr I think you need to change your double quotes to single quotes in your preg_match statements. regarding the other error, try $anno_device = $row["anno_device"]; as that's how you've coded it in your SELECT statement
April 27, 201214 yr eregi() has been Deprecated since php 5.3 you need to use something like preg_match
April 27, 201214 yr Author FIXED (changed).... LINE 185: if (preg_match("/".$Match."/", $agent)) { LINE 247: $anno_device = $row["anno_device"]; Thank you everyone for your help. Scotty
April 27, 201214 yr Author Spoke too soon. It works perfect in IE broser. When I test in Chrome, Safari and Firefox I get the following error... Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/root/wi_class_files/autoMakeLinks.php:15) in /home/myglobal/public_html/root/res.php on line 45 // ------- ESTABLISH THE PAGE ID ACCORDING TO CONDITIONS --------- if (isset($_GET['id'])) { $id = preg_replace('#[^0-9]#i', '', $_GET['id']); // filter everything but numbers } else if (isset($_SESSION['idx'])) { $id = $ckinOptions_id; } else { Line 45: header("location: index.php"); exit(); } // ------- END ESTABLISH THE PAGE ID ACCORDING TO CONDITIONS ---------
April 27, 201214 yr the message 'headers already sent' means that something has already been sent to the browser and you can therefore not redirect. Since you're using sessions, the session_start() function must be the first thing the script does. You need to ensure that nothing has been sent to the browser - even a white space or a carriage return will trigger this error. Check that there are no blank spaces after the initial <?php tag and session_start(). One way round this is to use output buffering - this method stores everything sent to the browser in temporary storage. At the end of the script you need to call ob_end_flush which 'flushes' out the buffer and sends the lot to the browser. Look up ob_start, ob-end_flush and ob_end_clean in the php manual. ob_start() would have to be the very first command in your php script.
April 27, 201214 yr Try testing if your headers our sent first if they are you can use a javascript solution /**If headers not sent perform a PHP redirect**/ if(!headers_sent()){ header("Location:index.php"); exit; }else{ /**If headers already sent perform a JS redirect**/ echo " <script type='text/javascript'> window.location = 'index.php'; </script> "; } this is just a quick fix but the best thing is to find out whats being outputted first then fix it using just a php redirect Edited April 27, 201214 yr by webdesigner93
Create an account or sign in to comment