Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





While Loop Inside If (!empty($_FILES['file']['tmp_name']))


when i press the submit button it tries to go to the new page but it seems like it just keeps loading something over and over and over the $myid variable is an integer like 23, or whatever.

<?php
 if (!empty($_FILES['file']['tmp_name']))
    {
      while ($row = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id='$myid'")))
      {
        $oldphoto = $row['myphoto'];
        echo $oldphoto;
      }
}
?>




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Upload A File The Variable $_FILES['foto']['tmp_name'] Isn't Set.
I moved to a new server. there the following error occurs: when trying to upload a file the variable $_FILES['foto']['tmp_name'] isn't set. it is not a bug since it all works fine on my pc at home and on the old server. i guess it could be a problem of php configuration or read/write permissions and that the temporary file has not been written.

View Replies !   View Related
Preserve $_FILES['file1']['tmp_name']; For Move_uploaded_file()
To use the move_uploaded_file(), basically we need to have the following:

Form:
<input type="hidden" name="MAX_FILE_SIZE" value="5120000" />
<input type="FILE" name="file1" value="{file1}" size="50">

PHP:
$file1_tmp = $_FILES['file1']['tmp_name'];
$file1_name = $_FILES['file1']['name'];
$file1_size = $_FILES['file1']['size'];
$file1_type = $_FILES['file1']['type'];

Upload: Code:

View Replies !   View Related
$_FILES[$field_name]['tmp_name'] Dirname Missing Trailing Slash
I've beat my head every way I can think of against this wall. Maybe
someone here just knows the answer.

I'm testing an upload class on my laptop WAMP server. When I run the
test script, everything is fine. When I put together my own form and
test uploading the same file, it fails because the
$_FILES[$field_name]['tmp_name'] value is missing the trailing slash at
the end of the temp dir name, so that the temp name looks like this:

c:/wamp/tmpphp11.tmp

instead of:

c:/wamp/tmpphp11.tmp

as in the packaged demo script.

I know that this value is set in php.ini. But that can't be the
problem as everything works fine in the demo script. As far as I can
discern, this value -- the temp dir name -- is handled internally by
PHP and not affected by the script, so I can't even check the value and
add the slash if it's missing. So my question: does anyone know why
the trailing slash is being dropped in my script?

I've tried every variation I can think of. I even tried to replicate
my error in the demo script by changing some of its form settings. I
can't get the two script to do the same thing with this
$_FILES[$field_name]['tmp_name'] value, even though everything else
should be equal.

All I can figure is that it has something to do with the forms' x/html
settings. The only other significant different between the two scripts
is that mine posts to itself and the demo to a separate page.

Anyway, if you can answer this for me, you'd really make my day! :)

View Replies !   View Related
FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the
size defined in the form or larger than upload_max_filesize in php.ini,
that _FILES['file']['error'] should hold an INT error code.

The file upload system is working fine if the file is smaller than the
defined size, but if it's larger, then both the _POST and _FILES arrays
are completely empty:

array(0) {
}

I can obviously check to see if $_FILES is set and contains elements,
but I was hoping for more specific error handling (reason as to why the
upload failed).

Has anyone else encountered this? Any info welcomed =)

View Replies !   View Related
From POST To GET: $_FILES Empty
I'm passing the code from $_POST to $_GET.

I've a page upload using $_FILES. when the page was in $_POST, it worked
fine, but now, in $_GET, the $_FILES is empty.

View Replies !   View Related
$_FILES['oppfil']['name'] Is Empty?
I'm having a problem on one server when uploading files. The code is in use in about 10 other servers, so it should be working properly. What happens is this:

$_FILES['oppfil']['tmp_name'] is set, but the $_FILES['oppfil']['name'] is empty (or it contains a '/').

$_FILES['oppfil']['error'], $_FILES['oppfil']['size'] and $_FILES['oppfil']['type'] is also empty. Does anybody know whats happening?

View Replies !   View Related
Help With Str_replace & $_FILES Arrays Need To Loop?
Ok I am trying to get these loops figured out

I have 10 files being uploaded- $_FILES['pic1-10']

I need to run str_replace on all 10 to eliminate any oddities " ","%20"
to clean up the filenames before inserting names in db.

foreach ($_FILES as $n) {
$name=$n["name"]
str_replace( " ", "",$name)

now how do I get it read back into $_FILES['pic1']['name'] and continure on
to pic2?

View Replies !   View Related
Where To Find File Upload Tmp_name On Server?
Can someone tell me where to find tmp_name on my server; the place where temporary file uploads are stored?

View Replies !   View Related
Creating A For Loop Inside Another For Loop.
I'm trying to write a script that will display questions that are in one flat file and answers from another flat file. In addition, there are copies of these files with their own data in multiple folders.

I created a for loop to work with an array of the different file paths to the different folders. Then I created a for loop inside of that one to display the questions and answers files that is in each folder. All I get when I run the script is the first folder and it's questions and then it stops there. PHP Code:

View Replies !   View Related
Loop Running Inside A Loop
Having a problem with the following; PHP Code:

$last_id = mysql_insert_id();
    
$type_count = count($types);
    
for ($i=0; $i < $type_count; $i++) {
        
$match = "";

if ($types[$i] == $featured[$i]) {
    $match = "y";
    }
                    
    $q_add_types = "INSERT into company_ins (Id, company_id, ins_id, type_featured) VALUES ('', '$last_id', '$types [$i]', '$match')";
        mysql_query($q_add_types) or die(mysql_error());
}

The INSERT query does not run when I insert the inner parenthesis. Does anybody know why?

View Replies !   View Related
If Statement Inside For Loop
Trying to build a script that sets selected if that is the value in the database (script modefied with static values for forum.)

What is does is make a dropdown box according to the number in stock, then it should selected the number that the customer has already selected.

The error is that it adds 'selected' to all values.

View Replies !   View Related
Getting Maximum Value Inside A Loop
I'm using something like this, to output a table of rows:

// Set max_val
$max_val = 0;
// Do the loop
while ($row = mysql_fetch_assoc($result)) {
$max_val = max($max_val, $row['integer']);
// etc etc
echo $max_val;
// etc etc
}

I want the maximum value of $row['integer'] to be available in every row. The above example does this, with the exception of the first (top) row of the table, where $max_val is then the value of $row['integer'] for that row - not the actual maximum for all rows.

View Replies !   View Related
UPDATE Inside A WHILE Loop
I have a WHILE loop that steps through a set of retrieved records, depending on the status of a checkbox from a form, specific records will be updated.

Problem is I get an error "Warning: Supplied argument is not a valid MySQL result resource in codetest.php on line xxx" PHP Code:

View Replies !   View Related
Queries Inside A Loop
Can you create queries inside a loop? Probably in a 'do while' loop.

The problem I've hit is that I have a web app for a sports team. On one page we enter how many tries(touchdowns) they scored, and then this number of drop-down menus appears on the next page, filled with all the possible players. The user then selects the players who scored and submits the form.

This action should then create a new record in the 'tries' table for each try scored (in other words, for each drop-down menu).

I've got it so that I can create one try automatically using the code below, but is there a way I can loop this so it repeats for every try? I've named them try1, try2, etc.

$createtry_sql = sprintf("INSERT into tries (tryOpponent, tryTeam, trySeason, tryPlayer) VALUES ('%s', '%s', '%s', '%s')",
   $_SESSION['creatematch']['opposition'],
   $_SESSION['creatematch']['ottersteam'],
   $_SESSION['creatematch']['season'],
   $_POST['try1']
   );
$createtry_query = mysql_query($createtry_sql) or die(mysql_error());

View Replies !   View Related
Loop Inside A Variable
How do I put a final output from a WHILE loop in a variable and echo it outside of WHILE?PHP Code:

while ($row = mysql_fetch_array($result)) {
  $names = ''.$row['name'].'<br>'//outputs 10 names
}
echo $name;//all the 10 names.

View Replies !   View Related
Query Inside Loop
I am trying to do a simple drill down that queries a table, loops the data, but inside of each loop I would like to do another query using the rowid and the userid to see if a record exits. I don't think a join would work(?) because if the corresponding row doesn't exist in the other table, it wouldn't display the data from the first table, right?

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM content";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$contentdesc=mysql_result($result,$i,"contentdesc");
$contenttimereq=mysql_result($result,$i,"contenttimereq");
$contentfileloc=mysql_result($result,$i,"contentfileloc");
$contentid=mysql_result($result,$i,"contentid");
..........

View Replies !   View Related
Recall A Function Inside A Loop
I'm running through two arrays making sure the values do not match
each other and if one value in array b does match a value in array a,
what I want to happen is:

foreach($arrayb as $key => $value){
if($value == $array[$getrandnumb]){
$getrandnumb = getrandnumb($result);
// I want to recall this function to get another number
// but it needs to jump OUT of this foreach loop so it can then
// be run again.
$taken = 1;
} else {
$taken = 0;
}

}

How can I do this?

View Replies !   View Related
Variables Inside A Foreach Loop
I have two arrays that have Spring and Fall specific dates.
They do exactly what I want but, when I put them on the same page, the
first array, Spring months, prints out then the second array, Fall
months, prints out and then the first array prints out again. Its not
supposed to do that at all. However, I dont see what is causing the
second printing of the first array.

Here are the two arrays.....

View Replies !   View Related
Using Mysql UPDATE Inside For Loop
I have an array that stores pieces of information that I want to update to a database. I decided to use the for loop to retrieve the peices of information and one by one store them into the database. The last peice of the array is stored repeatedly for the other values....

I have echoed the process the loop takes and i cannot figure out the problem... Here is a simplified version of my code:

View Replies !   View Related
How Do I Enter A Do While Loop Inside A Variable?
How do I enter a do while loop inside a variable?

$email_address = do { code_here } while

I want to call $email_address later and have it populated with all the available email addresses. It's going to be an email link like this

echo '<a href"=mailto:',$email_address,'">Click Here</a>

I want it to generate a new email message with all the email addresses in the To: line. I just can't get a loop running within the initiall variable settings.

View Replies !   View Related
For Loop Inside Of Echo Statement
I am having an issue with this code. I have a for loop with an echo statement and I want to automatically make the variables change as my table echos out:

for ($i = 1 ; $i <=$actual_number_of_stories ; $i++)
{
echo"<tr><td>$i</td><td><input type=text name=1floor_area_occ1 size=2 >ft<sup>2</sup></td></tr>"
}

The second iteration I want the same thing, but I want to change the 1floor_area_occ1 size to 2floor_area_occ1 size And then 3floor_area_occ1 size etc, etc. I want to use that $i in front of the floor_area_occ1, but I can't get there.

View Replies !   View Related
Placing Loop Inside Array...
I need to put a loop inside an array, but when I try this it won't work. Is it even possible to do this? My code is as follows. PHP Code:

$bar_data=array(
while ($row=mysql_Fetch_assoc($get))
{
                  $row[name] => 52,
}
               );

The error I get is:

Parse error: parse error, unexpected T_WHILE, expecting ')'...

Could anyone help me with this please? Is there another way I could use?

View Replies !   View Related
How To Nest A Loop Inside An Array?
I am trying to nest a loop inside of an array, to simplify the array. Code:

View Replies !   View Related
File Upload - Nothing In The $_FILES Array After Selecting A File And Clicking Submit
I have to following HTML form to upload a file:

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<input name="userfile[]" type="file" />
<input type="submit" value="Submit" />
</form>

In my upload script I have:

if(is_uploaded_file($_FILES['userfile']['tmp_name']))
{
..do some code, etc.
}

There seems to be nothing in the $_FILES array after selecting a file and clicking submit. Any ideas why? All I get is this when trying to echo some of the $_FILES variables: File Array is Array bytes, i.e. the word Array is just being printed instead of the relevant info.

View Replies !   View Related
Endless Loop? Empty Variables? What IS Going On?
1. it appears to be endless, as it freezes up my browser and never really ends

2. the variables are empty in the loop period .....

View Replies !   View Related
How To Nest A Loop Inside An Array? Part II
I had this challenge and laserlight and leatherback helped me thru it, but now I am trying to get the data for this dynamic array from a query and I get...

---drop down menu start---
1 (1st record, I just get a value)
2 (end record, I just get a value)
3 (3rd record, I just get a value)
John Doe (I get the correct name)
---drop down menu end---

I know I am close, but I've tried many variations with no success.

So I throw myself on the mercy of the forum.

PHP Code: ....

View Replies !   View Related
Need 200+ SELECT Statements Inside A Foreach Loop
I have to query 4 tables in order to get the final result. But using left join to query all the tables together is just too slow.

If I perform the queries seperately, I will need 200+ SELECT statements inside a foreach loop. Both approaches take about 10 seconds and 5 seconds respectively. Is there anyway to optimize the SQL query?

View Replies !   View Related
Should The $result Be Placed Inside The While Loop Or Is It Correct In Its Current Position?
Should the $result be placed inside the while loop or is it correct in its current position? Code:

View Replies !   View Related
Form Inside Loop, Need To Wait Till Submit Is Activated.
I have the following.

$result=mysql_query($sql);
$nrows=mysql_num_rows($result);
for ($i=0;$i<$nrows;$i++)
{
$row_array=mysql_fetch_row($result);
echo "<form name='testform' action='ins_op.php' method='post'>";

lots of form stuff

echo "<td><input type='submit' value='Save'>";

echo "</form>";
}

I'd like to have the loop wait until the form submit is pressed before
it continues and grabs the next record from $row_array.

Right now the code displays all the records with their submit buttons.

Doing it in this form permits one query to the database to get all the
open records.

View Replies !   View Related
While Loop Issues, Fatal Error: Cannot Access Empty Property..
I am having issues with a while loop in a modified script. It gives me
the error "Fatal error: Cannot access empty property in fb2phpbb2.php
on line 146" If i comment out the loop. The script does populate the
table. Because the script was designed for php 4.x, I think its just a
syntactical issue. More info can be found at...

View Replies !   View Related
Can't Upload File To $_FILES
I'm trying to figure out why I can't upload a file in php.
I'm trying it locally on a windows XP machine running Apache 2.2 and
PHP 5.2.1.
That is I am running the browser/server on same machine to test with.
I also tried it on a remote linux server, though in that case I'm not
sure what the s
config settings where, except that it does have PHP and I get the same
results.

Are there any releevant apache settings ? I have not come accross any.

Below is my script, results, and config settings.

=------------------------------------------------------

<html>

<body>

<?php

if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?>
<form enctype="mutlipart/form-data" method="post" action="<?php echo
$_SERVER['SCRIPT_NAME'] ?>" >
<input type="file" name="document"/>
<input type="submit" value="Send File"/>
</form>
</body>
</html>
<?php }
else
{
echo "FILE=";
print_r($_FILES);
echo "</br></br>POST=";
print_r($_POST);
}

--------------------------------------------------------

on a post I get an empty $_FILES object and something in the $_POST
variable from the above prints:

FILE=Array ( )

POST=Array ( [document] =feedblitz.txt )


# my php config file has these settings which I also verified with
phphinfo()

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default
if not
; specified).
upload_tmp_dir = "c:playsoaptest";

; Maximum allowed size for uploaded files.
upload_max_filesize = 5M

View Replies !   View Related
Upload More Than 1 File Into $_FILES?
Is it possible to upload more than 1 file into $_FILES? For ex. $_FILES['file1], $_FILES['file2], $_FILES['file3].

View Replies !   View Related
$_FILES['File']['type'] Returns Nothing
I have an MP3 Upload site, but when a user logs in and uploads a file, more than half of the time the MP3's MIME type returns absolutely nothing!

I don't think it's the code, because some of the music uploads well, it's just about 65% has no MIME! Any explanation?

View Replies !   View Related
File Field Validation $_FILES??
I have the following code that validates my form fields. I have a file field called file that I cant figure out how to validate. Code:

View Replies !   View Related
Upload A Pdf File Using The $_FILES Built In Array
I'm trying to upload a pdf file using the $_FILES built in array

It gets stalled at this point and displays the echo

if(!ereg("image",$_FILES['pix']['type']))
{
echo "<b>File is not a picture. Please try another
file.</b><br>";
include("illustup.inc");
exit();

This is the content of the $_FILES array
Array ( [name] => 000.pdf [type] => application/pdf [tmp_name] =>
C:PHPuploadtempphp2D.tmp [error] => 0 [size] => 26596 )

is it the 'type' thats wrong or the "image", I'm assuming I'm missing
something in the mime type.

If I try to load a gif file using the same script, it works fine.

View Replies !   View Related
FTP Commands To Handle File Upload Rather Then $_FILES
I'm builidng a file upload for a client, their server's admin refuses to up the max file size in PHP.ini from 2M to what I need 70M

Since I cant change the PHP.ini, I'm wondering if I use FTP commands to handle file upload rather then $_FILES, will it still be subject to max file size?

View Replies !   View Related
$_FILES Fill In The File Inputs Without Browsing Again
I have a form with some required fields and some file submission fields as well. I do some form validation after submission and if they miss a field that is required I want to fill in the fields that they did fill out to save them some time. Is there any way to fill in the file inputs or do they have to browse for them again? From what I can tell, the path of the file doesn't get passed with the form, but I just wanted to confirm that.

View Replies !   View Related
Upload Issue - Tmp_name
The issue I am encountering is mainly to deal with tmp_name I have this html for to submit the file: PHP Code:

View Replies !   View Related
PHP Upload Progress Indicator And Tmp_name
I spent the last couple of days setting up a progress indicator for a
private site that only does a couple uploads a day. After figuring out
there was no way to set the 'upload_tmp_dir' or 'tmp_name' per
session, I resigned to just doing an opendir() and finding the one
file in 'upload_tmp_dir' since I knew there would never be an issue
with multiple uploads occuring at the same time.

if(is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh))) {
if(eregi("php", $file)){
$fp = fopen("$dir$file", "r");
$fstat = fstat($fp);
echo "Bytes uploaded: " . $fstat[7] . "<br>
";
fclose($fp);
closedir($dh);
$done = 0;
}
}
}
}

This works ok and I just do a JS popup with a meta refresh to show how
many bytes have been uploaded so far. I'm not concerned with knowing
the actual filesize, only showing that the upload is working and how
fast it's working, as you can see in the code above.

After all this, the question came to mind as to why it would be
difficult or a security problem to prepend or append something like a
timestamp or sid to the tmp_name so that one could reliably figure out
which tmp file they needed to stat? As would be the case with multiple
uploads. I've looked through the PHP source, specifically
php_open_temporary_file.c and don't see what the problem would be, but
then I'm not an expert at C or PHP.

View Replies !   View Related
Write To File Sometimes Deletes EVERYTHING, Leaving Empty File
I've used PHP to save raw data from Flash to an XML in the past. Load the XML into flash, update a couple variables, then send it to PHP to completely overwrite the old .xml file. This works great most of time, but sometimes after a few days, I'll check the .xml and it will be empty (0 bytes).

Not sure if this is caused by a user who aborted during the writing process, or simultaneous connections, etc. Been thinking about doing a backup every day using CRON, but that's a mission and I'd like for it not to happen full stop. Any suggestions?

View Replies !   View Related
Include A PHP File Inside A PERL File
I want to include a PHP file inside a PERL file. script1.pl #/usr/local/bin/perl

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
print header();
warningsToBrowser(1);
print("<?php include('require_file.php') ?>
");

View Replies !   View Related
File Upload Works But Only For Empty File
I can upload a file as long as it is empty (thanks Hendri Kurniawan).
I do not know where to look.

Can someone help me understand what I need to do to upload a small image.
http://chops.novatrope.com/game/test/upload_file3.php

Here is some more info http://chops.novatrope.com/info.php

View Replies !   View Related
Instead Of Downloading The File It Just Downloads A 4kb Empty File.
I am using this code:

header("Content-type: application/ZIP
");
header("Content-disposition: attachment;filename=$file
");
readfile($filelocation);

And it works great on many servers. But on this server I am trying to get it working on now, instead of downloading the file it just downloads a 4kb empty file.

View Replies !   View Related
PHP File From Inside PHP
I have a form, the results of which do a database (mysql) query, to give a list of authors. The user can then select the author to get further information. This uses a link with a get which sends the information to another php script called get_auth.php. What I want to do is to run this get_auth.php script directly from the first PHP script if there is only one author, without having to bother the user with an unecessary click.

View Replies !   View Related
How Can I Use Css/xml Inside My Php File For Formatting
What I'd like to do is use xml in my php file for use with my css.  I noticed php can read from xml files to get data but can I use xml in my php file like how xhtml uses xml.  As in can I use xml with css for presentation  rather than as data entry. If you know what I mean.

View Replies !   View Related
Can I Run PHP File Inside A HTML File?
I want a count file(PHP) to be executed when a HTML file requested. How can I do this? I have no idea about excuted a PHP file inside a HTML file.

View Replies !   View Related
Sessions File Is Empty
php 4.4.6
windows xp
iis 5

After upgrading php to 4.4.6 after using 4.3.9 all session files are empty. The file is created but blank. I have checked the sessions folder has permissions for IUSR.

I have also tried every thing here http://bugs.php.net/bug.php?id=16263

View Replies !   View Related
PHP Session Is Empty And Session File Is Empty
I am trying to save a SESSION variable which looks to succeed because right after I print it out to verify it. I do so as follows:

session_start();
<snip>
$_SESSION['security_code'] = $code;

The problem is that I submit a form on the same page and I need to check if the $_SESSION['security_code'] == $_POST['security_code'] however this condition is always false because $_SESSION['security_code'] is empty.  I also checked the security files that are created in the PHP 'save_path' directory and it appears to be creating an empty session file.

Can anyone suggest anything here?  Also prior to the condition, I also do a session_start() and that doesn't help either.

I got this code from a open source area and on that web site, if I test it it works fine.  On my localhost it does not work.  I'm not sure if I'm missing some configuration or whether PHP 5.2.2 has problems with sessions.

View Replies !   View Related
I Want To Define Something Inside A File Into A Variable
I want to open and read a file into a variable. Then i want to define things in that variable to a diffrent variable.Example:

The variable page = <html><head><title>{title}</title></head>

If there any way i could define {titile} to write out the contents in trhe variable $title ?

Here is what my current code looks like:
define("{title}", $title);
$placeforstyle = "styles/style.php";
$placeforstyle = $mainactual.$placeforstyle;
$fd = fopen($placeforstyle, "r");
$outputstring = fread($fd, filesize("$placeforstyle"));

fclose($fd);
$fp = fopen($pagesactual.$filename, "w");
fwrite($fp, $outputstring);
fclose($fp);

View Replies !   View Related
Extracting Data From Inside A PHP Tag In A File.
I need to find a line in a file, such as: <?php $title="This is the text I want." ?>
and insert only what's inside the quotes into a mySQL table. I have no trouble using strstr() to find the <?php $title= part, but then my "needle" returned contains all of the rest of the file from that point on.

So how would I "extract" that information from inside the file? Or even all of the text that is between <h2> and </h2> tags, for instance?

View Replies !   View Related
Include File Inside A Class?
is it possible to do this I keep getting errors:

class myClass{ include_once('myfile.php');}

View Replies !   View Related
Can I Put PHP Code Inside Javascript .js File?
I have a javascript .js file, can I have php code like <?=$myvar;?> inside the .js file? will it work?

View Replies !   View Related

Copyright © 2005-08 www.BigResource.com, All rights reserved