Illegal Offset Type For Array. Object To Integer Convertion
The code is as ...
$folderlistfile = $path."xmlfile.xml";
/*
<list>
<details id="2">
<name>Books</name>
<mainid>0</mainid>
</details>
<details id="1003">
<name>CDs</name>
<mainid>0</mainid>
</details>
</list>
*/
$list = simplexml_load_file($folderlistfile);
foreach($list as $sno=>$details) {
if($details->isdeletable) {
if($details->mainid) {
echo "<br /mainid = ".$details->mainid." : id =
".$details['id']." ";
var_dump($details->mainid);
$mainid = $details->mainid;
settype($mainid, "integer");
var_dump($mainid);
// I want to save the details in an array
//$listarr[$mainid][] = $details['id']; //Warning: Illegal offset
type
//$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" }
UNKNOWN:0
mainid = 0 : id = 1003
object(SimpleXMLElement)#4 (1) { [0]= string(1) "0" }
UNKNOWN: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
either
$listarr[$mainid][] = $details['id']; //Warning: Illegal
offset type
or
$listarr[$details->mainid][] = $details['id']; //Warning:
Illegal offset type
View 1 Replies (Posted: July 27th, 2006 11:55 AM)
Sponsored Links:
Related Forum Messages:
Illegal Offset Type?
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:
Posted: 07-15-2005, 03:02 PM
View 3 Replies!
View Related
SimpleXMLElement And Warning: Illegal Offset Type?
Warning: Illegal offset type i have this var from an xml output var_dump($key); 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?
Posted: Mar 2 at 11:13
View 1 Replies!
View Related
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. [Code.........] 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.
Posted: Dec 17 10 at 23:27
View 3 Replies!
View Related
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?
Posted: March 08, 2007, 11:17:56 PM
View 5 Replies!
View Related
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: <?php $xml = simplexml_load_file("eurofxref-daily.xml"); $array=array(); foreach ($xml->children() as $cubeMain) { [Code]...
Posted: Apr 3 at 8:31
View 1 Replies!
View Related
Access Array Object With AMF / Getting Error "Cannot Use String Offset As An Array"?
I have an array in AS3 that I am sending to AMFPHP var myArray:Array = [ {type:"text", title:"title 1"}, {type:"video", title:"title 2"},[code]... In my PHP function I need to loop through the array and get to the objects for ($i = 0; $i < count($myArray); $i++) { $type = $myArray[$i]['type']; $title = $myArray[$i]['title']; } The above doesnt appear to be working.I also tried $type = $myArray[$i]->type; $title = $myArray[$i]->title ; AMFPHP is returning this error: Code: [Select]Cannot use string offset as an array
Posted: January 29, 2010, 02:30:49 PM
View 6 Replies!
View Related
Cannot Use Object Of Type * As Array
I think my webhost recently updated their PHP to version 5 and I now get this nasty error: Quote: PHP Fatal error: Cannot use object of type users as array in E:**wwwrootplannerlibsite.lib.php on line 102 The line 102 in site.lib.php is PHP Code: if ($_SESSION['user']['logged_in'] == true) { Wich worked fine. The $_SESSION['user'] is set when logging in by this line: It seems like $userq is a object now instead of a array. Did they change this in php5? I tried to use PHP Code: if ($_SESSION->user->logged_in == true) { But that didnt work either.
Posted: April 14th, 2010, 12:40 PM
View 13 Replies!
View Related
Cannot Use Object Of Type StdClass As Array
I'm leveraging SOAP calls to retrieve an array of values based. What I can't figure out is how to get to the values (eg-name, ssn, etc) once the entire array has been returned. If I try something like: $results[1], I get the error: Cannot use object of type stdClass as array.Code is below. PHP Code: if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); set_time_limit(0); require_once("./include/nusoap/nusoap.php"); [code].....
Posted: February 28th, 2011, 04:11 PM
View 5 Replies!
View Related
Error: Cannot Use Object Of Type StdClass As Array'
Derp.Getting 'Fatal error: Cannot use object of type stdClass as array' I dunno what I'm doing wrong here: foreach ($json->result->items[$key]->attributes->attribute as $attrib => $val) { if($json->result->items[$key]->attributes->attribute[$attrib]->name == 'cannot_trade') { $notrade=1; echo 'Item ' . $key . ' is not tradeable' . $br; } }........
Posted: Apr 1 at 16:03
View 2 Replies!
View Related
'Cannot Use Object Of Type StdClass As Array' Using Wordpress
I am trying to retrieve the slug for a tag inside a wordpress post, now its possible to get all tag info using $tag = wp_get_post_tags($post->ID); More info on this on the Wordpress Docs By using this you should get data returned like this... Array ( [0] => stdClass Object ( [term_id] => 4 [Code].... Now what I want is the slug for the first item which should be as follows $tag[0]['slug'] However by doing so I recieve this php error: Cannot use object of type stdClass as array
Posted: May 30 at 2:04
View 1 Replies!
View Related
Getting Error: Cannot Use Object Of Type Mysqli_result As Array?
I'm following a php pagination tutorial that uses MYSQL but I use MYSQLI object oriented all around my site. This is causing some errors.. For this part.. $sql = "SELECT COUNT(*) as num FROM categories"; $total_pages = $connection->query($sql) or die(mysqli_error($connection)); $total_pages = $total_pages['num']; I get *Fatal error: Cannot use object of type mysqli_result as array*.. on the last line so I switched it to $sql = "SELECT COUNT(*) as num FROM categories"; $total_pages = $connection->query($sql) or die(mysqli_error($connection)); $row = $total_pages->fetch_assoc(); $total_pages = $row[num]; and now I get Use of undefined constant num - assumed 'num' ..on the last line. At this point, I'm not sure what else to do.
Posted: Jul 31 10 at 18:50
View 2 Replies!
View Related
Cannot Use Object Of Type StdClass As Array Error
I am trying to make my php login check if the user has a verified account or not, I'm doing this by either "0" or "1" in the uses table, 0 meaning its not and 1 meaning it is. My problem is I keep getting the following error: Fatal error: Cannot use object of type stdClass as array in /home/rawradam/public_html/login2.php on line 31 Here is the code to go with it: if($row['verify'] == "0"){ echo "Your account has not been verified."; } I don't know if I'm miles off the ball or if I am doing the right thing, but just getting it mixed up,
Posted: Posted 12 December 2009 - 01:51 AM
View 5 Replies!
View Related
Accessing Object Properties Of Type Array Dynamically?
I am building a Language class for internationalization, and I would like to access the properties dynamically (giving the string name), but I don't know how to do it when dealing with arrays (this is just an example): class Language { public static $languages_cache = array(); public $index_header_title; public $index = array( "header" => array( [Code].... So, outputting members: echo _('index_header_title', "en"); //works echo _('index["header"]["title"]', "en"); //does not work I would need a way for accessing arrays dynamically.. for public and private via __set() function.
Posted: Jan 25 at 21:52
View 1 Replies!
View Related
IMAP : Fatal Error: Cannot Use Object Of Type StdClass As Array
when I create test e-mail or I will forward the specific e-mail, the script works correctly - saves attachment into server disk. now, when I configure to check another mailbox, it gives me error: Num Messages 11 Fatal error: Cannot use object of type stdClass as array in /test/emailattach/index.php on line 34 index.php: Code: [Select]<?php $mbox = imap_open("{mail.server.com:143}", "email@email", "XXX") or die('Cannot connect to mail: ' . imap_last_error()); [Code]....
Posted: May 09, 2011, 01:55:45 PM
View 2 Replies!
View Related
Type Casting An Decoded Json Object To Array, Generate Error While Accessing It?
I decoded a json string and then Type casted it into any Array and tried to access it later. But it generate Undefined Index Error Here is my sample code $json = '{"1":"Active","0":"Inactive"}'; //Yes, it is a valid Json String $decodedObject = json_decode($json); $array = (array)$decodedObject; echo $array['1']; // This generates undefinded Index 1 Error Here is the display of the array and object stdClass Object ( [1] => Active [0] => Inactive[code]....
Posted: Mar 27 at 8:19
View 2 Replies!
View Related
Check What Type (integer, String Etc) A Database Field Is
If i have a datebase field like so: $username = $row['username']; //after SELECT and mysql_query etc. how do i check what file type it is? i have tried using is_string to check it but it returns all fields back as strings, even the ones i know are integers. i would like something that would tell me the data tyle (integer, varchar, text etc). are there any other ways or am i doing this wrong?
Posted: July 17th, 2005 07:51 AM
View 1 Replies!
View Related
Adding Results From Query 2 To Query 1 - Cannot Use Object Of Type Mysqli_result As Array
I make two queries and I'd like to add rows from query 2 to query 1. Also, suppose getResult1() returns no column called "item2" $result1 = getResult1(); $result2 = getResult2(); foreach ($result2 as $res) [code].... There error I get here is on line $result1[] = $data and reads Fatal error: Cannot use object of type mysqli_result as array I think I get what is happening, but I'm not quite sure how to fix it.The rows are ultimately getting converted to JSON, and I can do that that with an array of arrays.I've fixed the problem by converting $result1 into an array of arrays. I do this using a while loop and a fetch_array() call, but is there a quick way to just convert $result1 into an array of arrays instead of a record set?
Posted: Apr 29 at 14:44
View 3 Replies!
View Related
Datatypes - Convert Object To Integer?
The value of $total_results = 10 $total_results in an object, according to gettype() I cannot use mathematical operators on $total_results because it's not numeric Tried $total_results = intval($total_results) to convert to an integer, but no luck The notice I get is: Object of class Zend_Gdata_Extension_OpenSearchTotalResults could not be converted to int How can I convert to an integer?
Posted: Feb 24 09 at 19:19
View 4 Replies!
View Related
Using Object Paradigm On Atomic Integer Value For Display Purpose?
I am working on financial values for poker games. All amounts are internally given as cents. Therefore, the type is integer. But, I need to display the amounts in several ways. So far, I work like this (PHP) : class Amount { private value; public function set($v) ... public function get() ... public function add($v) ... // $v is integer [Code].... It works like a charm, but since PHP is not able to overload operators, my code is quite "heavy" and I am wondering if I am doing it the wrong way. Finally, is it still "object paradigm" to work like this : $value1 = 100; $value2 = 200; $val = new Amount($value1 + $value2); echo $val->display1(); The code is liter when doing operations, but I feel wrong creating a new Amount object each time I just want to display a value (and in this case the class name would be AmountDisplayer). My question : what is the correct POO way to work with integer values ?
Posted: Jan 13 at 11:26
View 1 Replies!
View Related
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 <?php error_reporting(E_ALL); [code].......
Posted: Posted 25 April 2010 - 12:26 AM
View 1 Replies!
View Related
Pdf To Jpg Convertion
I m trying to convert a pdf file into a jpg image but i did not find any way to do that except using imagemagick (i read that on a forum but i cant make it work !) does anybody has a solution or an idea to make that possible ? i cant imagine that we cant do it because convert a jpg file to a pdf is so easy and generate jpg file with GD too....
Posted: 10-14-2004, 06:23 AM
View 1 Replies!
View Related
Array Offset Is Set
I have a double-dimension arrays I can call the data: array[0][0] and array[1][1] The data displays properly, but i keep getting the error: Undefined offset. I can't figure out whats going on.
Posted: 11-10-2005, 04:29 AM
View 3 Replies!
View Related
Convertion Dates
I want to convert that date('U'); number into a date can i do that $ut = date('U'); $rt = 1173128934 + 86400; $tbthere = $rt - $ut; echo " $ut"; echo " <be>$rt"; echo " <be>$tbthere";
Posted: March 05, 2007, 04:22:42 PM
View 11 Replies!
View Related
Db Timestamp Convertion?
What is the correct way to convert from mysql timestamp (YYYY-MM-DD HH:MM:SS) to my own chosen format, something like "August 5, 2010"? iow how can I make the mysql timestamp php date() compatible?
Posted: Aug 4 10 at 12:55
View 4 Replies!
View Related
String Offset As An Array
PHP Code: <?php // Declare variables // $debug = false; $url = "http://www.mto.gov.on.ca/english/traveller/conditions/rdclosure.htm"; //$url = "./roadclosed1/rdclosure.htm"; $email_recip = "REMOVED"; #$email_recip = "REMOVED"; #$email_subject = MOVED TO LINE 47 $email_from = "WxServer Roads"; $email_from_addr = "REMOVED"; $message_header = " ====START==== .......
Posted: 06-29-2007, 06:45 PM
View 3 Replies!
View Related
Can't Use Sting Offset As An Array?
I just updated my homeserver to PHP 5.3.1 and I get now the following error when executing my scripts: Cannot use string offset as an array The variable looks like: $bes[$a[3]][$a[4]][$a[6]], where $bes is a three-dimensional array that holds all information I need during runtime. The $a's can basically hold the information about a location, a day and an hour. So after runtime I have a nice smooth table of all information I need for a place and a time. So the problem is, that the main variable causes the problem. Replacing it with something new means to rewrite the whole code. And this is as you know awful work and costs quite a few bucks. The old server (online): Apache 2.0.54 / PHP 4.3.10-22 (Debian, I guess) My new home server: Apache 2.2.14 / PHP 5.3.1 (opensuse 11.2) So has anyone experiences with reorganisation of old PHP-4-code? I tried to use intval() to make all possible strings to ints but that doesn't seem to do the trick.
Posted: Mar 4th, 2010
View 3 Replies!
View Related
Cannot Use String Offset As An Array
I know the problem that I am having is related to the change in PHP5 about strings and arrays, however I do not understand why my script is affected. It seems like I am not trying to add more variables to an array. // Build View Array if ($view_result!=false) { $i=0; while ($view_row =@ mysql_fetch_array($view_result)){ $i++; [Code]....
Posted: January 10, 2011, 10:02:42 AM
View 2 Replies!
View Related
|