Argument To Keys() Should Be An Array In Main.inc On Line 152
I am getting the following errors:
Warning: Argument to keys() should be an array in main.inc on line 152
Warning: Non array argument supplied for foreach() in main.inc on line 152
I've developed the site on my linux box at home using PHP 4.0.3pl1. It works great, but when I upload it to my hosting service I get the above messages. I've tried all the different ways to go through an associative array. I've tried doing an implode(array_keys($arr), ',') then split on ','. It keeps coming back to the fact that it doesn't recognize the array I declare right before it is an array.
The hosting service runs a BSD Bosx and uses PHP 4.0b2. I'm wondering if this was a problem with the second beta release or if it is something screwy between platforms.
Why does it work great on my box but when I upload it it craps out?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Using Array_intersect() Without Keeyping Keys From The Array1, I.e. Re-number Intersect Array Keys.
I only use indexed arrays. When I use array_intersect function, of $a3 = array_intersect( $a1, $a2 ), I just need the vales of intersect array and let keys to be re-numberred from 0.; I found the intersect array $a3 have the correct values but keep the keys of $a1. When I use for loop from $index=0 to sizeof ($a3)-1, by $a3[$index], php reports "undefined offset " problem. How can I re-number the keys of $a3 from 0 to sizeof($a3)-1;
Main Program Call Another Main [GET]
is it possible to call from a main program another one the same as it is done by the browser? If I begin I am able to do http://server/main.php?name="test" in the browsers URL. Could I do such a submission inside of a program and how?
Using Max() On Array Keys
i am using an array to store contact data within a session. it looks like this: $_SESSION['contact'][$key][<content>] $key counts the set of records, so i have $_SESSION['contact'][Ɔ'] $_SESSION['contact'][Ƈ'] $_SESSION['contact'][ƈ'] and so forth. [<content>] stands for the fields containing the actual set of data, which are stored within the [$key]-arrays. at one point i need to find out what the highest value of $key is. running max($_SESSION['contact']) simply leaves me with "Array()" as the result. what i am doing wrong, and how do i correct it?
Array Keys
is it possible to use only a key in an array meaning: $arr["a"]="yo"; $arr["bc"]="ygo"; $arr["eea"]="wgyo"; $arr["fa"]; $arr["a"]="yo"; and then somehow get all the keys without and value i tried: while (list ($key) = each ($arr)) {print $key;} but i doens't seem to work.
Array Keys
If I used a "for each" to go through an array or irregularly numbed keys, is there a way to get the key number that the loop is currently on each time?
Array Keys
Been trying to figure out an array issue. For some reason when I echo $key it's echoing "Array". I want it to return the key (in this case adventure). Code:
Automatic Array Keys
My array keys are behaving strangely. In the manual it says calling an array like $array[] = "something" should make the value be put into the next available integer key available. However, my values are being placed with whole sets of blank keys inbetween. Here's what part of the print_r() of the array returns: Code:
Print Out Array Keys Only
Hi, there are lots of examples that show you how to print array values given a key. Do you know how to print keys for a given array. example $myArray = array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4); How do you print 'a', 'b', 'c','d' only without using any loops?
Printing Out Array Keys
i'm trying to find a simple way of printing out the keys in an array generated by mysql_fetch_array which returns a single row. i.e. while ($row=mysql_fetch_array($result) ) { print out the $row keys and values } is this possible?
Write Array Keys To SQL
I have an array of data. I want to write each key in the array to its own row in SQL. what would be the best way to accomplish this?
Foreach Loop With Array Keys
I am unable to get the following piece of code to work as desired. The fields valuable seems to contain all values however the vaules variable only contains the first assignied with $values = ''' . $arry[$keys[0]] . ''' $keys = array_keys($arry); $fields = '`' . $keys[0] . '`' $values = ''' . $arry[$keys[0]] . ''' foreach($keys as $key) { if($key != $keys[0]) { $fields .= ', `' . $key . '`' $vaules .= ', '' . $arry[$key] . ''' } }
Prepend Array Keys With A String
I have looked on uk.php.net for the function I need but can't find it. Does anyone know what the function is called who's purpose is: to recurse through an array and assign values to keys whilst prepending the key name with a string specified by one of the function parameters?
Getting Deep Array Value Without Knowing Keys?
I've racked my brain for the last few hours trying to figure this one out. I have an array of language strings such as : $lang = array(); $lang['en']['prompt']['hello'] = 'hello' $lang['en']['prompt']['bye'] = 'goodbye' $lang['en']['number']['first'] = Ƈst' This is being used by an ajax routine, so I don't know which string will be requested at runtime. So, I've got $lang and a request ('en_prompt_hello'), and tried a few things such as: $request = explode ($request); $found_string = array_intersect_assoc ($lang, $request); to no avail. Short of having to do a complicated recursion searching at every available depth, is there an easy way to do this?
Multibyte Strings As Array Keys
Does this work? Something is breaking when I try to do this, and all I can think of is that PHP does not allow multibyte array keys.
Sort An Array Using 2nd Dimension Keys
I need to sort an array (configured as shown) based on one of the second dimension keys. [1] ['File_Name'] => test.doc; [1] ['File_Type'] => MS Word; [1]['Size'] => 50; [2]['File_Name'] => test.pdf; [2]['File_Type'] => Adobe PDF [2]['Size'] => 150 [3]['File_Name'] => test.xls; [4]['File_Type'] => MS Excel; [5]['Size'] => 60; For example, I'd like the order of the 1st dimension keys (integer indices) to reflect the order if the array is sorted by the "File_Type" key.
Warning: Extract(): First Argument Should Be An Array In
I'm creating a program to edit the details of members of an executive committee stored in a MySQL database. However, I recently have started getting the following error: Warning: extract(): First argument should be an array in (lists file name and location of error) To give a little background, the user selects the member to be edited from a drop-down list, which then passes the execID associated with that position to this program, which then queries the table for all the details of that particular member. However, I get the above mentioned error located to the line after "extract($row)". I'm sure the solution to this is obvious to more experienced users, but I am baffled as I have used an almost identical setup for another project without experiencing the same error. I appreciate that the results of a query are loaded into an array, but I don't understand why a one-row result should cause such an error. PHP Code:
Array Processing - Invalid Argument
I have been trying to get this working all afternoon. I am writing a script to process a huge survey and store the form values in a database. EVERYTHING works but this one array (from HTML form). I'm sure it is a small problem. Here is the error (I echo other arrays to test that my loop works properly before and after the one with the problem, as can be seen by the printed values.): Web Developers Client Services Database Developers Web Developers Marketing Consulting Database Developers Warning: Invalid argument supplied for foreach() in /export/home/sevanet/twright/public_html/clientsurvey/temp/survey_handler.php on line 44 Code:
Getting Keys/values From POST Array In An Orderly Fashion..
I've got this javascript that results in the following being posted; weight_1 = 30 cost_1 = 20 amount_1 = 32 weight_3 = 65 cost_3 = 23 amount_3 = 12 weight_7 = 43 cost_7 = 9 amount_7 = 12 etc.., with the numbers appended to the keys (here 1, 3, and 7) ascending but not sequential. I need my PHP recieving these POST keys/values to present them like this: #1 Weight: 30 Cost: 20 Amount: 30 #2 Weight: 65 Cost: 23 Amount: 12 #1 Weight: 43 Cost: 9 Amount: 12 Whats' the right way to do this? I've been messing around with array functions but haven't quite figured out which to use..
Doesn't Like Index.php For Main Page
I've built a website and some of the pages are php pages (e.g. SomePage.php). It all works fine; both the html pages and the php pages come up and work just fine. I then made a change to the main index.html file and made it so that it's an index.php file instead, and it has some php code embedded in it, not much different than any of the other php pages on my site. But when I try to go to that index.php file, as the first file to bring up for the site, it fails to bring up the page but instead pops up an Open File dialog, asking if I want to Open or Save the index.php file. It's as if the server is not recognizing index.php as being a php file that needs the normal php pre-processing on the server side. I used to get similar prpoblems with the other php pages before I had my server properly set up with Apache and php and such. But all of that is indeed properly set up. The OTHER php pages come up OK. It's just the very first, index.php page, that doesn't come up correctly. What am I doing wrong?
Auth With PHPLIB In The Main Page
I need to add the login boxes in my main page. I use PHPLIB and I see that I can define a login page, but this login page should not be the main page. So, how I can login in the main page?
When Is The Php Code Loading To Main Memory?
I got some problems for php performance. I have big php file which size is around 70K. And When i request simple one it is too slow. So i printed time stamp to find which part is slow. And i finally found some facts. When I printed time stamp in a function it takes less than 10 ms. But When i printed time stamp out of fuction, starting above the include statement which includes 70k php file, it takes more than 1000 ms. I heard that php code is loading to main memory only one time except when it's modified. Only when php file modified it loades the php code to main memory again. Is it wrong concept?
Refresh Main Window After Download
I have a web application where the main window shows a list of records available for download. The user clicks on the download button, which posts the form to another ..php page, which generates the file for download and pops up the download dialog. So far, so good. My question is - how do I refresh the main window once the download dialog box has popped up? I need to clear the list of records from the main window (since the user downloaded it). The download is generated by another page, and not the main one.
PHP Move_uploaded_file From Subdomain To Main Domain.
How do you move files from a sub domain to a main domain? It gives me an error and won't allow it even though I've changed my folder permission to 777. move_uploaded_file($_FILES["file_name"]["tmp_name"],"http://www.maindomain.com/titles/$new_file_name" ); It works though if I make the paths relative to the sub-domain. (I've got a development server dev.maindomain.com and all the paths are relative...so I made all absolute paths to write to but it doesn't work. I'm linuxed based..)
Destroy Session On Close Of Main Window
When the user logging in my system i am registering new session session variable (eg. $user_authenticated = 'yes'. When the user exit from my page i want to unregister that variable $user_authenticated.
Warning: Main(): Stream Does Not Support Seeking ....
I have the following warning message when I move all the php files to the new server. It had no problem with the former server. Warning: main(): stream does not support seeking in /home/dominator/public_html/footer.php on line 11 MySQL is running with PHP. How could I fix this problem?
Warning: Main(): SAFE MODE Restriction In Effect.
There are 2 values for safe_mode . Local and Master. Why is local value OFF and Master value ON. I want my safe_mode to be OFF on server, becoz it is giving me this error: Warning: main(): SAFE MODE Restriction in effect. The script whose uid is 33 is not allowed to access ../../../../library/CConnection.php owned by uid 0 in /var/www/vhosts/default/htdocs/publisher/abhi1234/Tv_today/issue2/magazine.php on line 2 Warning: main(../../../../library/CConnection.php): failed to open stream: Success in /var/www/vhosts/default/htdocs/publisher/abhi1234/Tv_today/issue2/magazine.php on line 2 Warning: main(): SAFE MODE Restriction in effect. The script whose uid is 33 is not allowed to access ../../../../library/CConnection.php owned by uid 0 in /var/www/vhosts/default/htdocs/publisher/abhi1234/Tv_today/issue2/magazine.php on line 2
Main(PEAR.php): Failed To Open Stream: No Such File Or Directory ...
I have been trying to follow along with a tutorial on creating a PHP login script, which uses PEAR DB classes. However, once everything is set up and I atempt to run any of the .php files I get the following error: Warning: main(PEAR.php): failed to open stream: No such file or directory in c:php4pearDB.php on line 30 ...
Processing Data From Multiple Multi-line Textareas Into A Multi-dimensional Array
I know that this sounds like something overly complex - because it is. However, if I can keep the user interface the way it is, my users will be ultra happy! That is the goal... In general, this is an inventory receiving piece of an overall larger web-based ERP system. What I have is a form in which I have a dynamic number of multline textareas for inputting (possibly barcode scanning in) many serial numbers per line item recieved. For example: lineitem01 = widget01; qtyReceived = 2; lineitem02 = widget02; qtyReceived = 3; lineitem03 = widget03; qtyReceived = 10; This would display a form that will generate 3 textarea elements (1 per lineitem received). Inside each textarea element will be input the serial numbers for each of the widgets received per lineitem. i.e. 2 serial numbers will be entered for widget01; 3 for widget02; and 10 for widget03; So, what I am trying to do is pass this data over, possibly as a multi- dimensional array to another form ( or possibly $_SERVER['PHP_SELF'] ) to update a MySQL database to store the widget/serial numbers.
PHP & Javascript New Window Forces Main Page To Load Blank Screen
I have a problem with a call a Javascript "window.open()" function which is executed as part of a PHP file when a user clicks on an thumbnail image. The PHP is executed which passes some variables to Javascript to execute the new window opening. But as it does this, the main window is loaded which is blank (the browser URL bar shows the URL of the URL passed to the PHP / Javascript script). I would like to keep the gallery page visible in the main page which is where the link originally came from, so the user can see the gallery underneath the "popup" window of the called graphic. I don't know how much of an added problem it is, but the script that generates the whole sites pages is in the root directory, and the gallery HTML is in some seperate sub-directory and is "included" into the page layout (using variables passed on a page click). Gallery script calling the PHP file to execute on image thumbnail click: <a href="php/pics.php?&gal=coll01&picID=01"><img src="img/gallery1/s-dg01.jpg" ALT="Picture 1" width="30" height="69"></A> <a href="php/pics.php?&gal=coll01&picID=02"><img src="img/gallery1/s-dg02.jpg" ALT="Picture 2" width="74" height="69"></A> This passes the variables to the other PHP script which picture to grab. PHP file with the Javascript (pics.php): <?PHP // Section to generate the Javascript pop-up for correct // dimentions of the proposed pop-up. $URL = '..img/gallery1/dg'.$_GET['picID'].'.jpg' print "<script type="text/javascript"> <!-- var Jurl="$URL"; "; ?> window. open(Jurl,"Picture","width=370,height=260,toolbar=no,menubar=no, resizeable=no"); //--> </script>
CLI ( Command-line ) PHP Displaying Source Code In-line When Programis Executed
I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly without problems. Very amazing to use VMware, it has worked beautifully. uname -a Linux xxxxxxx 2.6.13-15.8-default #1 Tue Feb 7 11:07:24 UTC 2006 i686 i686 i386 GNU/Linux php -v PHP 4.4.2 (cli) (built: Feb 7 2006 20:13:29) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies php -m [PHP Modules] bcmath bz2 calendar ctype curl dbx dio domxml exif ftp gd gettext gmp iconv mcrypt mssql mysql ncurses openssl overload pcre posix session shmop sockets standard sysvsem sysvshm tokenizer wddx xml yp zlib When I run the following program from the command line it prints out the source code as well as the output from the program. I run other PHP programs on the command-line and this doesn't happen. It's really peculiar. The error output is below. I copied this off of php.net, and have modified it only slightly to allow command-line input. I was trying to find a CSV solution, which I ended up finding elsewhere, but am curious why this program would error out the way it does--have I misconfigured something? My php.ini is basically unchanged, if at all. I think I might have set the path to mysql but that's about it. When I run this program from the web it works without error. <?php if ( $argv[0] ) { $file = $argv[0] ; } else{ $file = $_GET['file'] ; print "<font face=arial> " ; } $row = 1; $handle = fopen("$file", "r"); while ( ( $data = fgetcsv($handle, 1000, ",") ) !== FALSE ) { $num = count($data); print "$num fields in line $row:<br> "; $row++; for ($c = 0; $c < $num; $c++) { print "$data[$c]<br> " ;
How To Return Just First-line From A Multi-line String Of Text?
I've been looking through the manual for string commands, and I haven't had success in determining the proper call for this, if there is one: Let's say I have a text string with hard-carriage returns in it: "The lazy brown fox ran down the road to the store and bought some eggs to bake a cake and serve dinner for all his friends." So if that string value is in "x", how can I tell it to return JUST the first line: "The lazy brown fox ran down the road"
Open File, Add Line At Beginning, Remove Last Line
I'm trying to open a file, write one line at the very beginning, and delete the last line. Right now I'm stuck at trying to open the file and write a line at the very beginning. Here's my code: $f="myfile.txt"; fwrite(fopen($f,"a"),"Add This Line"); I know I'm opening this file in append mode, where it will always write my text at the end of the document, but I can't figure out any other mode that would allow me to open an existing document and not delete everything that is already in it.
Primary Keys
How is it that even though I have the column "username" in my database set as a Primary key, using my PHP script to add new users to the database works without any errors even when signing up using an existing username. I have a database full of the same usernames!
Shortcut Keys
I would be liek to be able to set up a webpage with shortcut keys so that when certain buttons are presses, a pop up window will open with a designated further page displayed. Specifically I would like the shortcut keys to be a couple of the function keys, ie f10, f11 and f12.
Reading Files Line By Line Backwards
I'm new to PHP, and I'm trying to write something for my website. I have coded a game together with a friend of mine, and as with all new games and programs, it's full of bugs. What I would like to do, is write a page where everyone can post bugs (I have this part, not that hard). Then it should be read from the textfile they're all in, but backwards, so the newest bugs at the top of the list. Also I would like to add an option for me to login using a username and password, to mark bugs as fixed, or delete certain bugs from the list. I have the user part covered too, but I don't know how to delete a single line in the textfile.
PRINTing A Large String – Line By Line Or In One Go?
In many of my apps I read in a HTML file line by line, do some string substitutions and then print out the file line by line to the browser, for example: $fragment_to_show_handle = @fopen("page.html", "r"); while ( !feof($fragment_to_show_handle) ) // while not end of file { $line = fgets($fragment_to_show_handle, 1000); $line = str_replace("%pics%", $pics, $line); // do the substitutions one at a time $line = str_replace("%currency_select%", $currency_select, $line); // etc print "$line";// print the line to browser } fclose($fragment_to_show_handle); Alternatively, in another app I have done this: $home_html = implode ('', file("$fragments/home.html")); $home_html= str_replace("%applet_code%",$applet_code,$home_html); $home_html=str_replace("%pics%",$pics,$home_html); // etc print "$home_html"; Assuming the total output to the browser is the same, say about 20-50k, which approach is more efficient in a php/apache/unix environment in terms of speed and least server load?
Read Text File Line By Line
I have been given a textfile which contains data on 1000 businesses. Each line contains a name and a code which are seperated by a comma. The code below allows me to display the entire textfile but I want to read in the values from each line and store these in a database. $filename = "businesses.txt"; $fileToOpen = fopen($filename,"r"); $content = fread($fileToOpen, filesize($filename)); $content = nl2br($content); fclose($fileToOpen); echo($content); Does anyone know how I can read the data in line by line so that I can store it in a database.
|