Illegal Offset Type?

Jul 15, 2005

I am getting the following warning:

Warning: Illegal offset type in C:path on line 17

there is nothing on line 17, so I started looking back... everything lools fine. What am I missing? Code:

View 3 Replies


SimpleXMLElement And Warning: Illegal Offset Type?

Warning: Illegal offset type i have this var from an xml output

its give me
object(SimpleXMLElement)#11 (1) { [0]=> string(5) "Cairo" }

now i want make "Cairo" as a key to get its value like

$lang[] = array('Cairo' = "Cairo city");

the error appear when do this

echo $lang[$key];

and its give me the "Warning: Illegal offset type" because of the key is SimpleXMLElementhow i can make it normal var?

View 1 Replies

Illegal Offset Type For Array. Object To Integer Convertion

The code is as ...

$folderlistfile = $path."xmlfile.xml";


<details id="2">
<details id="1003">


$list = simplexml_load_file($folderlistfile);

foreach($list as $sno=>$details) {
if($details->isdeletable) {
if($details->mainid) {

echo "<br /mainid = ".$details->mainid." : id =
".$details['id']." ";
$mainid = $details->mainid;
settype($mainid, "integer");

// I want to save the details in an array
//$listarr[$mainid][] = $details['id']; //Warning: Illegal offset
//$listarr[$details->mainid][] = $details['id']; //Warning: Illegal
offset type

echo, var_dump will output as follow ...

mainid = 0 : id = 2
object(SimpleXMLElement)#5 (1) { [0]= string(1) "0" }

mainid = 0 : id = 1003
object(SimpleXMLElement)#4 (1) { [0]= string(1) "0" }

Both of this generate the error : Warning: Illegal offset type

$listarr[$mainid][] = $details['id']; //Warning: Illegal offset type
$listarr[$details->mainid][] = $details['id']; //Warning: Illegal
offset type

and page doesn't execute furthur of this line.

I suppose it is because the array key is an object. How do I convert it
to integer.

print_r($details->mainid) displays SimpleXMLElement Object ( [0] =0
print_r($mainid) : nothing is displyed. even mainid = 0 : id = 2 is
not displayed.

System: free bsd, php 5

As is mentioned in the code, I want to craete an array as

$listarr[$mainid][] = $details['id']; //Warning: Illegal
offset type
$listarr[$details->mainid][] = $details['id']; //Warning:
Illegal offset type

View 1 Replies

Warning: "Illegal Offset Type In <file Location>example.php"

I've been having considerable trouble trying to figure out why my arrays weren't working as expected. I was using code functionally the same as the code below, but it was silently failing on me in my program, so I wrote an isolated test case using the same types of data and syntax and got the errors about illegal offset types.

Warning: Illegal offset type in <file location>example.php on line 12
Warning: Illegal offset type in <file location>example.php on line 16

Those refer to the two lines containing the reference to "$questions[$question]" specifically.


I think I'm just beyond my skill level here, because while I can see the warning on [URL] that states "Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.", I cannot see how what I'm doing is any different than Example #7 on that very page.

View 3 Replies

Illegal Offset

I want to pass a class into an array, but I seem to be doing something illegal. here is the details

$characterListing = array($me=>$me->GetIsPlayer(), $him=>$him->GetIsPlayer());
error message: Warning: Illegal offset type in c:InetpubwwwrootMyProjectsSecondOfferinghtmlFns.php on line 133

How can I get around this?

View 5 Replies

Illegal Offset Using Dynamic Variable?

I dont unserstand why do i get such errors:

Warning: Illegal offset type in
index.php on line 10 USD 1.4141
Warning: Illegal offset type in
index.php on line 10 JPY 118.56

Here's my code:

$xml = simplexml_load_file("eurofxref-daily.xml");
foreach ($xml->children() as $cubeMain) {


View 1 Replies

Warning: Pack() [function.pack]: Type H: Illegal Hex Digit G In /code?

i am having some problems using pack() in php

$currencypair = "EUR/USD";
$buy_sell = "buy";
$alert_device_token =array("a","a","b");[code]...

Now sometimes i get following warnings running the same code -

Warning: pack() [function.pack]: Type H: illegal hex digit g in /code/FR2BVl

the illegal hex digit keeps varying though.

View 1 Replies

Socket Server "Undefined Offset" And Wrong Resource Type E?

This is a continuation of the same script, but I have come upon a new error.If I have a client leave the server, the socket server goes crazy and starts looping extremely rapidly after firing off a series of errors about attempting to close the socket.If another client tries to join after this, then the "Undefined offset" error starts recurring again and again.

#!/usr/local/bin/php -q

View 1 Replies

Change Current User Timezone Based On Server UTC Offset And User UTC Offset?

im writing a twitter web service in php. When a user signs in, i receive this node:


I have to change the script's timezone so that it adapts to the user's real timezone. The only php function i have found for this is: date_default_timezone_set($timezone_identifier) but it won't let me use -18000 as a the $timezone_identifier parameter.So, how can i change the current user timezone based on two values: Server UTC offset and User UTC offsetBTW, this is how i'm getting the server UTC offset value:

$this_tz_str = date_default_timezone_get();

View 2 Replies

Illegal Offest

I have recently been writing a script which was running on a server with PHP3 installed. I finished the script and also decided I would use it with my other web site which has PHP 4 installed.

To make the change all I needed to do was update all references from .php3 and change them to .php including the name of the file. However when running the file I get the following errors.

Warning: Illegal offset type in /usr/local/etc/httpd/htdocs/testing/install.php on line 264

Warning: fopen("","w") - Undefined error: 0 in /usr/local/etc/httpd/htdocs/testing/install.php on line 265

Warning: Supplied argument is not a valid File-Handle resource in /usr/local/etc/httpd/htdocs/testing/install.php on line 267

Warning: Supplied argument is not a valid File-Handle resource in /usr/local/etc/httpd/htdocs/testing/install.php on line 268

The offending code is as follows:

View 10 Replies

Illegal Characters

How do I check if a user has entered an apostrophe or other illegal characters in a form field? Below is my code... PHP Code:

if(!$field || $field == ''')
$error_message['field'] = 'Please Remove Backslash or Apostrophe'

View 3 Replies

Illegal Query

I'm kind of new to mySQL but more used to Sybase/PHP. What is illegal about this query or can i not use combined query's in mySQL?

DELETE FROM manufacturers
WHERE manufacturers_id NOT IN ( SELECT manufacturers_id
products )

View 1 Replies

Removing Illegal Characters

I have an upload script for a photo and a caption. It all goes pear
shaped when I upload a character like ' " or / |
Is there anyway I can parse through the filename when submitting the
form and remove any illegal characters like this?

View 2 Replies

Check For Illegal Letters

If user is asked for a username and password in a form. How would you do a check in PHP to make sure that username and password has no illegal characters such as, new line, tab, / or , *, -, ., ,,, ", ', so on.

View 8 Replies

How To Prevent Illegal Distribution Of A PHP Script?

I wrote a script (payware) a few months ago and I discovered recently that there are a whole bunch of really bad people out there :) How can I prevent people from copying and distributing my script?

I had these ideas, but they all have a significant downsides:

1. Encrypt the php files

Pro :: This will secure the content of my files
Con :: A local component is needed on the server of the customer. I don't want to make the installation of the script more difficult so this is not an option for me.

2. Generate a unique key per customer and check the key on my server - Each script has a unique key and each time the script is executed, a check is performed on a database on my server.

Pro :: easy to implement
Con :: this could generate a lot of load on my server.

Are there any other options I missed? Who has experience with one of the above options?

View 1 Replies

Illegal Characters In FDF File - Stream

I have been working on a php script lately that merges results from a db
and an xml source and then populates a PDF through FDF. I have gotten
nearly everything to work except multi line javascript. I have tried
both of the following attacks on the problem to no avail.

First I tried setting the set_on_import directly... then I tried to set
all the javascript in a function and then call the function on load...
both of them generate illegal characters in the stream.

Both of these examples are in a for each that contain a $counter:

$js = 'this.getField("moveinready.' . $counter . '").display =
display.visible;' . "";
$js .= 'this.getField("moveinready.' . $counter . '").display =
display.visible;' . "";



View 3 Replies

Escape Illegal Chars In .ini-files?

The documentation on parse_ini_file states that you can't use these chars {}|&~![()^" in the value. Is there some way to escape these chars? I need to use them. Normal escaping with doesn't seem to work.

View 1 Replies

Remove All Of The Illegal Characters Globally

I've recently written a javascript RegExp to cleanse my data at the front end, I now need to do exactly the same for my PHP back end but not having worked in PHP for a while I'm having trouble.

var illegalChars = /[()<>,;:.~@#$!\%^&*'?()+={}`\/"[]]/gi;
var siteSuggest = $(this).val().toUpperCase().split(' ').join('').replace(new RegExp(illegalChars), "");

So, in summary, I want to remove all of the illegal characters globally, remove spaces & capitalize the variable as the variable will be used to create a database or table in sql.

View 2 Replies

Removing Illegal Characters From MySQL?

I use the following php to make sure people can't use illeagal characters in thier username.

PHP Code:

if(!ctype_alnum($username)) {

However, if users have already added non numerical characters including spaces in thier username how would i remove them via PHP or MySQL command. This is rather than doing it manually as I have many members on my site and I don't feel like going through them all.

View 5 Replies

Strip Illegal Characters RSS Feed?

I've generated an RSS Feed using PHP, but I need to strip all illegal characters.The strings will be in French, so minimum there are the accents. I could get rid of them by replacing the accented characters by non-accepted characters, but there may be others characters that I won't be testing for.

View 2 Replies

Function To Escape Illegal Characters

I have a query that I am populating a drop-down menu with. I need to escape illegal characters, but I'd like to separate it out from the page. Code:

View 2 Replies

Checking For Illegal Characters In An Input?

I am looking for the best way to ensure that any illegal characters are removed from an input.I have a user registration form and login page. What I want to do is prevent against sql injection and therefore should be limiting the characters that can be entered. For example I want a username to include only letters and numbers so I ideally want to strip out any white space, illegal characters such as " ' ( ) etc...My issue with this is with the password, I would ideally like the user to be able to put as complex a password as they would like, so how would i prevent against illegal characters in this instance??

View 6 Replies

This Program Has Performed An Illegal Operation And Will Be Shut Down

I have installed an Apache web server on my Windows 98 desk top. I use this server to test PHP/MySql scripts. I access these scripts located on my C: drive with an alias defined in httpd.conf.

On my browser I use http://localhost/alias/..... or to serve my pages.

I have recently set up a router to share my internet connection between two computers. The other computer does not have Apache, PHP or MySql installed.

Last night I started getting the following error when accessing php scripts which appears randomly.

"PHP This program has performed an illegal operation and will be shut down"

I tried to call the scripts using my machines IP, disconnected the router and recreated the database but still get the error. I'm not sure if this is an Apache, Lan or PHP problem.

View 5 Replies

PHP Input Checking - Checks For Illegal Characters

I have a HTML form where the user can type in certain values, but I
only want them to able able to submit integers (0-9). I post to a PHP
page with the following "snippit" of code (all the variables have been
properly assigned):

// Checks for illegal chars
$illegal_chars = array("`", "~", "!", "@", "#", "$", "%", "^", "&",
"*", "(", ")", "-", "_", "=", "+", "q", "w", "e", "r", "t", "y", "u",
"i", "o", "p", "[", "{", "]", "}", "", "|", "a", "s", "d", "f", "g",
"h", "j", "k", "l", ";", ":", "'", """, "z", "x", "c", "v", "b", "n",
"m", ",", "<", ".", ">", "/", "?");
foreach ($illegal_chars as $value) {
if (stripos($db_mysql, $value)) { $pass1 = "f"; }
elseif (stripos($db_postgre, $value)) { $pass2 = "f"; }
elseif (stripos($db_oracle, $value)) { $pass3 = "f"; }
elseif (stripos($email_basic, $value)) { $pass4 = "f"; }
elseif (stripos($email_exchange, $value)) { $pass5 = "f"; }
elseif (stripos($ftp_users, $value)) { $pass6 = "f"; }
elseif (stripos($domain_subdomains, $value)) { $pass7 = "f"; }
else {}

The code will not work, and I can't see why. The variables $pass1-pass7
aren't set after the foreach() loop, no matter what is in the input!

View 5 Replies

File Uploading With Illegal Characters On The Filename

I'm creating a file uploading system for a project, and I came across this problem: whenever I upload a file that has a filename containing illegal characters, it truncates the filename from the instance of the illegal character onwards, so, in effect, the filename 'birdie's-heart.jpg' ends up as 's-heart.jpg' when it's uploaded.

Am I missing something?

View 14 Replies

Sends The Email Successfully Even If There Is Illegal Charactors?

The remaining 2 problems are even though it validates the email address with preg_match and echos an error, it still sends the mail and it checks for invalid charactors but (you guessed it) it still send the mail.

The script works fine, it checks if email, name and subject are filled out and if not writes an advice on the page.

It also checks for illegal charactors and correctly formed email address and writes the error message correctly.

The problem is that it sends the email successfully even if there is illegal charactors and/or malformed email address, in other words it knows about the problems but doesn't prevent the email being sent. Code:

View 5 Replies

Copyrights 2005-15, All rights reserved