Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when using string functions

Status
Not open for further replies.

kathymac

Programmer
Nov 25, 2009
7
CA
Hello,

I have written the following php code:

<?php
$sTemp = msg[1];
$iLength = strlen($sTemp);
$sFind = ',Related';
$iPos = strpos($sTemp, $sFind);
?>

When I run this code, I am getting an error on
Line 2 and Line 4 saying "object required".
Does anyone know why I would be getting these errors?

I have used this php code on other servers before with no problem, but when I recently used it on a new server I am working on I get errors.


 
Where are you getting this error? The Browsers debugger?
Object required is not typically a PHP error. Looks like its a Javascript error.

Just for starters, what is msg[1] supposed to be. If its a PHP array its missing the $ to designate a variable.

If its a Javascript array, then you can do that because PHP and Javascript cannot directly interact in that fashion.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Definitely not a PHP error, as it doesn't produce errors through the Browsers Debugger like you show, but rather to screen, or to a log file.

What other JS do you have there?



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top