Warning: Invalid Argument Supplied For Foreach() Running On A OS X Machine Running Apache 1.x And PHP 4.x.
The following script was running on a OS X machine running Apache 1.x and PHP 4.x. I just moved the script over to a Linux machine running Apache 2.0.51 and PHP 4.3.8, and now the foreach line does not work. It says Warning: Invalid argument supplied for foreach()
in /var/www/localhost/htdocs/warehouse/whse_order_submit.php on line 39
Here is the script:
<?php
//get the variables from the other page
$id=$_POST['id_no'];
$sku=$_POST['sku'];
$description=$_POST['description'];
$order=($_POST['order_qty']);
$store=$_POST['store'];
$comment=$_POST['comment'];
$ip=$REMOTE_ADDR;
//check if store is empty
if(empty($store)) {
die("Store is required. Please press the back button and enter in your store.");
}
//connect to the database
require('../inc/database_conn.php');
//$month=getdate(mon);
//$day=getdate(mday);
//$year=getdate(year);
//$today=$year . "-" . $month . "-" . $day
$today=date('Y-m-d');
// create the unique order number
$headerqry = "INSERT INTO misc_order_header (order_date, store, comment, ip) VALUES ('$today', '$store', '$comment', '$ip')";
mysql_query($headerqry, $conn) or die(mysql_error());
$order_no=mysql_insert_id();
foreach($order_qty as $id_no => $val) {
if($order_qty[$id_no] > 0) {
$detailqry = "INSERT INTO misc_order_detail (order_no, id_no, sku, order_qty, order_date, store) VALUES ('$order_no', '$id_no', '$sku', '".$order_qty[$id_no]."', '$today', '$store')";
mysql_query($detailqry, $conn) or die(mysql_error() . "<BR>" . $detailqry);
}
}
View Complete Forum Thread with Replies
Related Forum Messages:
Warning: Invalid Argument Supplied For Foreach()
I am getting the following errors on my webpage Warning: Invalid argument supplied for foreach() in /home/patcheen/public_html/booking/includes/classes/Order.php on line 231 Warning: Invalid argument supplied for foreach() in /home/patcheen/public_html/booking/includes/classes/Order.php on line 235 The code it refers to is this    foreach($event_stat as $event_id=>$count){     if(!Event_stat::dec($event_id,$count)){return FALSE;}    }       foreach($category_stat as $cat_id=>$count){     if(!Category_stat::dec($cat_id,$count)){return FALSE;}    } and here is where $event_stat and $category_stat are declared and populated     $event_stat[$ticket->event_id]++;     $category_stat[$ticket->category_id]++; Any ideas? Have I given enough information? Thank you so much for taking the time to look over this. I'm not going anywhere until this is resolved.
View Replies !
MySQL Backup - Warning: Invalid Argument Supplied For Foreach()
I`m using the following code to list the tables, adding a checkbox next to the tables so I can select what tables I want to back up. However after submitting the form, I`m having this error. Warning: Invalid argument supplied for foreach() in C:Serverhtdocsadminincfunctions.php on line 6228 That line is: foreach ($tables as $table)in the performExport($tables) function. I`ve stared at this for hours now and I can`t see a problem. Code:
View Replies !
Error Message Warning: Invalid Argument Supplied For Foreach()
I'm having a hard time with the foreach statement near the bottom of this code. I'm getting this error message Warning: Invalid argument supplied for foreach() in The code is searching for children that belongs to a user then gets the childs information from the table "Children'. It then check to see if the child is a registered user in the table "users". Next it looks in the table "image_files" to see if the current user how is linked to the child has added a photo. The photo can be identified by the child_id which matches the child_stored in at the end of the string stored in details.
View Replies !
Invalid Argument Supplied For Foreach()
$items = is_array($a_items); if (isset($_POST['items'])) { foreach($items as $itemval) { echo "a atimes = " .$a_items['isbn']; $quoteid = 1;//$itemval['quoteid']; $isbn = $itemval['isbn']; $price = $itemval['price']; $quantity = $itemval['quantity']; //if ($itemval['sv_flag'] = "on" ){ $ret_val = insert_quote_items($quoteid,$isbn,$price,$quantity); //} }
View Replies !
Invalid Argument Supplied Foreach()
I'm having a bit of problems with a simple form to email. I have a .html page that has a form. I want the contents of the form to be sent to my email everytime the form is submitted. Here are my problems: 1) After pressing submit on my form, it takes me to a another page that says: Invalid argument supplied foreach() on line 9 and the next second sends me to the thanks page which I created after a user sends the form. 2) When I look at my email I receive a email, but when I open it, none of the contents of the form are available. In other words, it comes empty. Code:
View Replies !
Getting Invalid Argument Supplied On The Foreach() Statement
I'm running PHP 4.4.1. Getting Invalid argument supplied on the foreach() statement from the excerpt below: $res = mysql_query("SELECT data FROM simbands WHERE song = " . $lyric["lyrics_id"]) or die(mysql_error()); if (mysql_num_rows($res) > 0) { $rec = mysql_fetch_array($res); $bands = unserialize($rec["data"]); } foreach($bands as $key => $val) { print ("<a href = "" . $val["band_file"] . ".htm">" . $val["band_name"] . "</a><br />"); } This worked on PHP 4.3.11.
View Replies !
Running PHP/Apache On A User Mode Linux Machine, Where To Stick Mysql?
I hope no one minds me running this past them. I'm running a linux machine with with apache, php and mysql. This is not accessable from the internet. I want a server that is visable to the internet. For that purpose I am running a user mode linux machine and using apache on that as the external looking web server. This means that stuff I want to see on the outside is on a copy of apache that is doing little and does not get messed around with as much as my main copy of apache. I am not using mysql with it at the moment. If I do am I better running mysql on the user mode machine or running a second copy of mysql on a different port on the 'main' machine. I'm beginning to think the latter has advantages.
View Replies !
Invalid Argument Supplied ?
i am somewhat of a newbie and and having hell with this Script. WHen i run it i get : Warning: Invalid argument supplied for foreach() in C:InetpubwwwrootKubemailWWWaspedit1.php on line 20 And i cant figure out WHY. Please help! Code pasted Below. <? $Reg = new COM("IISSample.RegistryAccess"); $Aliases="HKEY_LOCAL_MACHINESOFTWAREIpswitchImailDomainskubemail.comUsers\_aliases"; ?> <? function EchoValues($strKeyName){ echo "<h3>Get values of ".$strKeyName."</h3>"; $reg->Values[$strKeyName]; echo "<b># subkeys = ".$Values.$Count."</b><br>"; echo "<table>Values Collection"; echo "<TR><TH align=left>Name</TH>". "<TH align=left>Value</TH></TR>"; foreach($Values as $k){ echo "<TR><TD>".$k.$Name."</TD>"; } } ?> <? EchoValues($Aliases); ?>
View Replies !
Invalid Argument Supplied
PHP Code: <?php $ImusSays = array('says' =>'those are some','says'=>'nappy headed','says'=>'hoes.'); foreach($ImusSays['hair'] as $var) Â Â Â Â { Â Â Â Â Â Â Â Â echo $var." "; Â Â Â Â } echo "</br> therefore Imus is FIRED!"; Â Â Â Â Â Â ?>
View Replies !
Warning: Mysql_error(): Supplied Argument.
I'm attempting to submit my PHP script for an eCard but I get the following error when I do so: Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in C:www......dbmysql.inc.php on line 43, Line 43 is: PHP Code:
View Replies !
Invalid Argument Warning
I'm getting a Warning: Invalid argument supplied for foreach() error message for this bit of code: foreach($_POST['healthConditions[]'] as $key=>$value) { Â Â Â Â Â Â Â Â Â Â Â Â if($count > 1){ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $_SESSION['saFormData'] .= " $value, "; Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $count--; Â Â Â Â Â Â Â Â Â Â Â Â } else {Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $_SESSION['saFormData'] .= " $value.<br>"; Â Â Â Â Â Â Â Â Â Â Â Â }Â Â } I've done some research that said that this warning either means you've got a string instead of an array or that the array is null. Mine is obviously an array because its data that's being passed from a form via post. However, the warning goes away if a user has checked any of the healthConditions boxes so I guess it's because the array can be returned as NULL if they don't check any. I tried putting $_POST['healthConditions'] = array(""); and even $_POST['healthConditions'] = array("anything"); The way the form is worded, the user needs to have the option of leaving all checkboxes blank.
View Replies !
Warning: Mysql_num_rows(): Supplied Argument Error
I'm receiving the error above in my shopping cart application. I sell one-off items and use Paypal as the payment engine. In the remote possibility an item was previously purchased I loop through each order and update one at a time. I'm counting rows so if a record is not updated, I'd like to know. Strangely, it's working as designed (sending emai), but don't want to deploy unless I know why this error is occuring. Here's what I've got so far. Here's the full error: 1. :confused: is not a valid MySQL result resource in cartworks15.php on line 105. 2. Do I need to change the variable to a different function. Is my syntax correct. Code:
View Replies !
Warning: Mysql_fetch_array(): Supplied Argument Is Not A Valid
When I run this script It says Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in blah blah. <? session_start(); include "db.php"; $username = $_SESSION['username']; $result = mysql_query("SELECT * FROM users WHERE to='$username'"); while ($row = mysql_fetch_array($result)) { ?> From: <? $row['from'] ?><br> Subject: <? $row['subject'] ?><br> Message: <? $row['message'] ?><br> <? } ?>
View Replies !
Running Batch Script On Remote Machine
I have a windows batch script that I've hosted on an FTP site (ftp://ftp.domainname.com/folder/script.bat). I have a link to it on a webpage. When a visitor clicks on the link the browser gives him the option to save or to run the file. If the user wants to save the file and look at it afterwards, he can. I do not want this to be possible. Is there a way to have the browser directly run the script on the visitor's PC while only giving him the option to run or not (just ask him for his consent) using PHP programming?
View Replies !
Warning: Feof(): Supplied Argument Is Not A Valid Stream
i am using fopen to open a webpage, it works great when the page is not located on a secure server but as soon as i point it to look at that page i get the following error Warning: feof(): supplied argument is not a valid stream resource in C:AppServwwwSJMDBv2database_eagaDupChecker.php on line 11 Warning: fgets(): supplied argument is not a valid stream resource in C:AppServwwwSJMDBv2database_eagaDupChecker.php on line 14 this is the code for the page in question $fp = @fopen("https://somesecured.server", 'r'); while (!feof($fp)) { $buffer = fgets($fp, 4096); echo $buffer; } fclose($fp); i have tried it on several diffrent server and the only one i can get working are the normal http.
View Replies !
PHP Warning: OpenDir: Invalid Argument (errno 22)
How I can get directory listing of CDROM (F: ) under Windows! I tried every combination of slashes! But nothing!!!! When I try to use opendir, I get error: PHP Warning: OpenDir: Invalid argument (errno 22) in c:apachehtdocs ester est.php on line 90 When I try with drive C: , it works, but with other drives not? Is this some kind PHP4 bug? My System: WindowsNT4.0 + Apache + PHP4.0.6.
View Replies !
Warning: Supplied Argument Is Not A Valid MySQL Result Resource
<? Warning: Supplied argument is not a valid MySQL result resource if (mysql_num_rows($result) >0 ) !Didnt have this problem before session_start(); if ($username && $password) { // if the user has just tried to log in $db_conn = mysql_connect("localhost", "*****", "*******"); mysql_select_db("micro_db.adf", $db_conn); $query = "select * from users " ."where name='$username' " ." and pass=password('$password')"; $result = mysql_query($query, $db_conn); if (mysql_num_rows($result) >0 ) { // if they are in the database register the username $valid_user = $username; session_register("valid_user"); } } ?>
View Replies !
Warning: Rewind() Supplied Argument Is Not A Valid Stream Resource In...
I am implementing Iterator in a class, I have pretty much copied the code from php.net on Object Iteration. Adding all the normal methods for the task...rewind, current, next, etc. I was attempting to add a seek method but am stymied by the above warnin, as well getting a seek on index 0 (zero) to work. public function __construct($contents) { if ( is_array($contents)) { if ( is_array($contents[1])) { $this->cktl = $contents[1]; } } } public function rewind() { $cktl = rewind($this->cktl); return $cktl; } public function current() { $cktl = current($this->cktl); return $cktl; } public function key() { $cktl = key($this->cktl); return $cktl; } public function next() { $cktl = next($this->cktl); return $cktl; } public function valid() { $cktl = $this->current() !== FALSE; return $cktl; } public function myseek($intPos) { $myPos = 0; $this->rewind(); while ( $myPos < $intPos && $this->valid() ) { $cktl = $this->next(); $myPos++; } if ( !$this->valid() ) { die("Invalid seek position"); } return $cktl; }
View Replies !
Warning: Fread(): Supplied Argument Is Not A Valid Stream Resource
am trying to upload images in MySql using php. whenever I run the following code I get this message: Warning: fread(): supplied argument is not a valid stream resource in C:webs estCNST ProjectsGenaral Upload FormfigUpload.php on line 6 config.php is where I assign the database, the user, and the password. openDB.php is where the database is opened closeDB.php is where the database is closed <?php include'phpFigures/config.php'; include'phpFigures/openDB.php'; include'phpFigures/assignValues.php'; if (isset($figpath)){ $figImage=addslashes(fread(fopen($figpath,"r"),filesize($figpath))); $query = "INSERT INTO images(description, image) VALUES ('$figdescription', '$figImage')";
View Replies !
Warning: Mysql_fetch_array(): Supplied Argument Is Not A Valid MySQL Result
Here is my script: <?php $dbh=mysql_connect("localhost", "my_username", "my_password") or die ('No can do!'); mysql_select_db ("my_databasename"); $query = "SELECT * FROM contacts"; while($i = mysql_fetch_array($query)){ echo $i[first]; echo $i[last]; echo $i[email]; } ?> Get this error message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/my_username/my_domain/my_databasename/test.php on line 6.
View Replies !
Counter - Warning: Fwrite(): Supplied Argument Is Not A Valid Stream Resource
I am trying to put one counter in my php with the next code: <?php $hitfile = "/admin/contador.txt"; if (!file_exists($hitfile)) { $file = fopen($hitfile,"r+"); $hits = fread($file,filesize($hitfile)); fclose ($file); } else { $hits = 0; } $file = fopen($hitfile,"w+"); fwrite ($file, ++$hits); fclose ($file); ?> but when i try to see the php page appears this error: Warning: fopen(/admin/contador.txt) [function.fopen]: failed to create stream: No such file or directory in /home/usuairo/pagina.php on line 9 Warning: filesize() [function.filesize]: Stat failed for /admin/contador.txt (errno=2 - No such file or directory) in /home/usuairo/pagina.php on line 10 Warning: fread(): supplied argument is not a valid stream resource in /home/usuairo/pagina.php.php on line 10 Warning: fclose(): supplied argument is not a valid stream resource in /home/usuairo/pagina.php.php on line 11 Warning: fopen(/admin/contador.txt) [function.fopen]: failed to create stream: No such file or directory in /home/usuairo/pagina.phpcontacto.php on line 19 Warning: fwrite(): supplied argument is not a valid stream resource in /home/usuairo/pagina.phpcontacto.php on line 20 Warning: fclose(): supplied argument is not a valid stream resource in /home/usuairo/pagina.phpcontacto.php on line 21
View Replies !
Warning Mysql_fetch_array(); Supplied Argument Is Not A Valid MySQL Result Resource?
i am getting the following error with this bit of code? Warning mysql_fetch_array(); supplied argument is not a valid MySQL result resource? Code: <?php /* Connect to database */ $extra = 'blah' $size= Ƈ' $paper= 'matte' $db= mysql_connect("localhost", "", ""); mysql_select_db("", $db); $sql="select type_id FROM type WHERE extra=".$extra." AND size=".$size. " AND paper=".$paper ; $type_id=mysql_query($sql); ............
View Replies !
Fopen :: Warning: Fwrite(): Supplied Argument Is Not A Valid Stream Resource
I tried to store the file pointer returned by fopen as a session variable. I get a warning: fopen to open stream: HTTP wrapper does not support writeable connections. Thisis followed by a bunch of: warning: fwrite(): supplied argument is not a valid stream resource if (!isset($_SESSION['fh'])) { $fh = fopen("http://www.mydomain.com/somedir/debug", "w"); $_SESSION['fh'] = $fh; } ...... ...... fwrite($_SESSION['fh'], " some debugging text msg: ".$msg."msg_type: ".$msg_type);
View Replies !
Warning: Mysql_num_rows(): Supplied Argument Is Not A Valid MySQL Result Resource In *** On Line 9
I keep getting an error result saying: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in *** on line 9 Warning: Cannot modify header information - headers already sent by (output started at ***:9) in **** on line 12 I'm pretty new to PHP so I'm thinking its a problem with syntax. Any help is appreciated. Code is below. <?PHP $ni = trim($_POST['ni']); require 'db_connect.php' $sql = "SELECT * FROM $db_table WHERE ni = '$ni'"; $query = "mysql_query($sql) or die (mysql_error())"; if (mysql_num_rows($query) < 1) { require 'db_close.php' header("location: DESIRED LOCATION"); } else{ require 'db_close.php' header("Location: EXIT "); } ?>
View Replies !
Warning: Mysql_select_db(): Supplied Argument Is Not A Valid MySQL-Link Resource In E:htmldbconn.php On Line 4
I submitted the question about text files I decided to have a go with a database instead though Im having problems connecting to the Database. As a PHP novice Im not entirely sure where Im going wrong but I have been getting the following error: Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in E:htmldbconn.php on line 4 Can't select entries from table. SELECT * FROM Entry ORDER BY Entry.entryDate DESC LIMIT 5 No Database Selected Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:htmldbconn.php on line 11 The code I'm using looks like this: ....
View Replies !
Warning: Mysql_num_rows(): Supplied Argument Is Not A Valid MySQL Result Resource In /mounted-storage/
my code: $username = mysql_real_escape_string($username); $result= mysql_query("SELECT * from `admin_login WHERE username=".$username); if (mysql_num_rows($result) != 0) { echo ("That Username is already being used. Please try a different username."); } I know that there is a row that has the same username as $username, but i keep getting an error like: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /mounted-storage/home23a/sub001/sc21473-GRUR/www/inphp/members/register.php on line 56 Line 56 being: if (mysql_num_rows($result) != 0)
View Replies !
Running PHP As CGI On Apache
I'm having what you could call a bad day, now I'm not an experienced user of PHP but I know enough to install scripts and get them looking how i want them to. I'm trying to install Gallery 1.2.5, unfortunatly my new virtual host runs PHP in safe mode which renders the script useless, after reading their FAQ I found that i can run PHP as CGI and place the script in there. Now I have a problem I cannot compile this on the server as i don't have the permissions or access to do so, is there anywher i can get a pre-compiled version of php.cgi with newbie type instructions?
View Replies !
Running Php On Apache
I just installed apache 1.3.11 and php3 on my linux (red hat) system. Both files were rpm. My server works but when I load a php3 file netscape displays the source of the file in stead of the results. Whats wrong with my server? How can I configure my server so php3 files are interpreted correctly? I don't know very much about linux.
View Replies !
|