homepage Welcome to WebmasterWorld Guest from 54.196.162.238
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
ERROR: Deprecated: Function eregi() is deprecated in and Notice: Undef
Scotty13




msg:4446512
 1:10 pm on Apr 27, 2012 (gmt 0)

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>';

}

 

cffrost2




msg:4446534
 2:13 pm on Apr 27, 2012 (gmt 0)

"This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged." - From php.com site.

A good alternative is the use of preg_match. (as I see you used earlier in your code ;) eregi() ignores case. preg_match can too by using the "/" modifier.
Change
LINE 185: if (preg_match("/".$Match."/", $agent)) {

Then for your line 247 error. you're not calling the correct variable.

$sql_annos = mysql_query("SELECT id, tkt_id, the_anno, anno_date, anno_type, anno_device....

//change
LINE 247: $anno_device = $row["anno_device"];


Hope this get's you going again. :)

Scotty13




msg:4446578
 4:00 pm on Apr 27, 2012 (gmt 0)

No errors! Thank you so much.

Scotty

Scotty13




msg:4446620
 5:49 pm on Apr 27, 2012 (gmt 0)

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 ---------

cffrost2




msg:4446749
 2:12 am on Apr 28, 2012 (gmt 0)

That warning pertains to 2 or more sources trying to work within the headers. Like there is an echo statment happening before the header call. Or another header call taking place before the one on line 45. Check both the res.php file and the autoMakeLinks.php file for conditions like that. May need to post more code to help further diagnose.

Could also be that your opening <?php tag has a white space before it or the closing ?> tag has a white space after it. Say on you res.php file, line #1 should be <?php. Sometimes, line 1 will be blank and <?php is actually on line 2. Same in your autoMakeLink.php file.

In other words, think about it like this. Headers can only be modified (header('location: index.php')) if nothing else has been posted/echoed to the browser already. This includes small things like white spaces. Be sure to scan the code and look for any potential code block making an echo/print or another header being sent before the one on line 45. Hope that's not too confusing. I tried to simplify it a bit.

g1smd




msg:4446766
 6:29 am on Apr 28, 2012 (gmt 0)

header("location: index.php");

Two other problems with that single line of code:
- the location should include protocol and domain name,
- never redirect to a named index page.

The correct canonical URL is http//www.example.com/ with a trailing slash.

Additionally, it's a 302 redirect. Is that what you want?

Scotty13




msg:4447281
 8:32 pm on Apr 29, 2012 (gmt 0)

In my autoMakeLinks.php I changed ereg_replace to preg_replace.

And, on the top of my profile page. added...

ob_start();
session_start();

Scotty13




msg:4447282
 8:33 pm on Apr 29, 2012 (gmt 0)

No errors! Hope it stays that way.

Thanks, Scott

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved