Php Fatal Error Cannot Use For Reading
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business laravel cannot use [] for reading Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Array_push
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like array push you, helping each other. Join them; it only takes a minute: Sign up Cannot use [] for reading up vote 21 down vote favorite 3 In one of my scripts, I try to do the following $data[] =
Php Foreach
self::get($row['sr_id']); // <-- line 55 However, PHP does not allow me to do this, giving me this error Fatal error: Cannot use [] for reading in /file.php on line 55 The self::get function return either a bool, or an object. Edit: The get function creates a new object which again loads data from a mysql database. php arrays fatal-error share|improve this question edited Sep 12 at 6:46 Nikhil Vaghela 1,2821422 asked Sep 29 '10 at 9:20 php array eriktm 3171314 2 Check what $row contains –Eiko Sep 29 '10 at 9:23 1 print_r($row) –Filip Ekberg Sep 29 '10 at 9:25 Can you show the surrounding code / the get method? –halfdan Sep 29 '10 at 9:30 1 Try to find out whether the error is about $data[] = or about $row['sr_id']. –Sjoerd Sep 29 '10 at 9:39 we need more context –Quamis Sep 29 '10 at 11:53 | show 2 more comments 4 Answers 4 active oldest votes up vote 11 down vote accepted Old PHP versions accepted $var[] in expressions, allowed reading out the $var content regardless of syntax. PHP 5.1 made that illegal. But sometimes the error is triggered outside of the intented context. So my guess (again: show more code) is that the preceeding line contains an unfinished expression, to which the $data[] joins. In case of object attribute you can wrap your $data var into { }, but that doesn't seem to be the problem in your case. (Else there is something in line 54, that you didn't show.) The right hand side can't reasonably trigger the error. Even array accessing [] an integer or object wouldn't trigger that fatal error. So if nothing helps, just use array_push(). Work around PHP. share|improve this answer edited Jan 29 '14 at 17:41 ak
Votes:31 Avg. Score:4.1 ± 1.0 Reproduced:30 of 30 (100.0%) Same Version:7 (23.3%) Same OS:15 (50.0%) From: mellow at mellow dot dk Assigned: Status: No Feedback Package: Scripting Engine problem PHP Version: 4.1.2 OS: Linux Private report: No CVE-ID: View Add Comment Developer Edit Have you experienced this issue? yes no don't know Rate the importance of this bug to you: high low Are you using the same PHP version? yes no http://stackoverflow.com/questions/3820258/cannot-use-for-reading Are you using the same operating system? yes no [2002-05-17 11:02 UTC] mellow at mellow dot dk I've build an array using the following in a function : ------------- $this->get_data(array("","","and D.XiParentId= 'gwak_root_element' ORDER BY D.vcOrder")); $arrCategory = $this->return_array(); for($i = 0 ; $i < sizeof($arrCategory) ; $i++) { $this->get_data(array("","","and D.XiParentId = '" . https://bugs.php.net/bug.php?id=17290 $arrCategory[$i]["XiDataId"] . "' ORDER BY D.vcOrder")); $arrItem[$arrCategory[$i]["vcItemId"]] = $this->return_array(); } return $arrItem; ------------- This constructs an array with values like : $arrItem["project_priority"][0] = array(...) $arrItem["project_priority"][1] = array(...) etc... Later I tried to do the following to the returned $arrItem : ------------- $arrItem["project_severity"][] = array("XiDataId" => "gwak_get_all", "vcText" => "All"); ------------- This gives the error : ------------- Fatal error: Cannot use [] for reading in /home/plb/public_html/gwak/module/project/include/Task.class.php on line 160 ------------- Funny because doing the following : ------------- $arrThis["here"][] = array("XiDataId" => "asdasdas", "vcText" => "324234234"); $arrThis["here"][] = array("XiDataId" => "asdasdas", "vcText" => "324234234"); $arrThis["here"][] = array("tr" => "ert"); $arrThis["where"][] = array("er" => "ert"); $arrThis["where"][] = array("we" => "ert"); $arrThis["where"][] = array("tr" => "ert"); ------------- gives no error at all, eventhough $arrThis and $arrItem have exactly the same format. Do you guys have an idea what is going on here? The only thing i can see could cause the problem is that $arrItem is built using "arrays within arrays": $arrItem[$arrCategor
Cannot use [] for reading The SitePoint Forums have moved. You can now find them here. This forum is now http://www.sitepoint.com/forums/showthread.php?548963-Fatal-error-Cannot-use-for-reading closed to new posts, but you can browse existing content. You can find out more information about the move and how to open a new account (if necessary) here. http://board.phpbuilder.com/showthread.php?10382074-Fatal-error-Cannot-use-for-reading-in If you get stuck you can get support by emailing forums@sitepoint.com If this is your first visit, be sure to check out the FAQ by clicking the link above. cannot use You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. SitePoint Sponsor User Tag List Results 1 to 2 of 2 Thread: Fatal error: Cannot use [] for reading Thread Tools Show Printable Version Subscribe to this php fatal error Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode May 17, 2008,23:03 #1 Shaun(OfTheDead) View Profile View Forum Posts Keep Moving Forward Join Date Nov 2005 Location Trinidad Posts 3,746 Mentioned 45 Post(s) Tagged 0 Thread(s) Fatal error: Cannot use [] for reading Fatal error: Cannot use [] for reading Has anyone ever seen that error message before? Anyone know what causes it ? I'm writing a PHP function and creating an array of the HTML output which I intended to implode at the end and return, but for some odd reason that error message keeps coming up at the implode line. I've double checked my syntax about fifteen times and everything seems right. Here's a simple function to illustrate... Code PHP: function deBugger() { $output_Debugger[] = '
'; $output_Debugger[] = 'Hello World'; $output_Debugger[] = '
'; echo implode("\n",$output_Debugger[]); } Am I missing something obvious? I have no idea why this souldn't be working. Thanks a lot in advance. Trying to fill the unforgiving minute with sixty seconds' worth of disyour first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 7 of 7 Thread: Fatal error: Cannot use [] for reading in Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 11-12-2011,02:07 PM #1 jone kent View Profile View Forum Posts Junior Member Join Date Nov 2011 Posts 4 Fatal error: Cannot use [] for reading in Hello i am new here also new in php i have problem with my code PHP Code: $seller_id=$listings[]['Account_ID'];
i get this error Fatal error: Cannot use [] for reading in the array is PHP Code:
$seller_info=$rlAccount->getProfileInfo($seller_id);
$rlSmarty->assign_by_ref('seller_info',$seller_info);
Array(
[0]=>Array
(
[