Hi
I am running a script
which includes the following lines
[code=php]
/*
* Now we get the pictures.
*/
if( $pict == “y”){
require_once(“a_picts.php”);
} // endif
else{
$N_pix1=$N_pix2=$N_pix3=$N_pix4=$N_pix5=”none”;
} // end else
$sql = “UPDATE homes SET
pix1 = ‘$N_pix1’,
pix2 = ‘$N_pix2’,
pix3 = ‘$N_pix3’,
pix4 = ‘$N_pix4’,
pix5 = ‘$N_pix5’
WHERE ad_ref = ‘$A_ref’ “;
mysql_query($sql)
or die(“could not execute HOMES UPDATE PICTURES query”);
Within the called a_picts.php is another require
stmt to include a form.
[code=php]require_once (“a_picts_fm.php”);
exit();
this form when submitted reruns a_picts.php in order to process it.
<form name=”main_fm” enctype =”multipart/form-data” action=”a_picts.php” method=”POST”>
OK – pretty std.
But when the a_picts.php has finished – it does not return to the script that called it. I was expecting it to return to the point just after it was called from and then continue executing the next statements i.e. update the homes table.
Well it doesn’t – a_picts.php gets to the end and then hangs – just stops.
Why is this – what have I done wrong ?
Thanks
[code=php]
<?php
/*
* homes_add.php
*
* Called by : homes_ad_btn.php
*
* Call a_picts.php to get the pictures
*
* processes the homes_add_fm.php which is the
* FORM for adding a home.
*/
if (!isset($_POST['run_mn'])){ // BIG IF the main form has NOT run.
PREPARES DATA AND CALLS MAIN FORM ( NOT PICTURE FORM)
else { // BIG else - SO MAIN FORM HAS RUN
VALIDATES FORM DATA
/*
* Now we get the pictures.
*/
if( $pict == "y"){
require_once("a_picts.php"); // < -- HERE IS THE CALLING
} // endif
else{
$N_pix1=$N_pix2=$N_pix3=$N_pix4=$N_pix5="none";
} // end else
// I WANT TO RETURN BACK HERE
$sql = "UPDATE homes SET
pix1 = '$N_pix1',
pix2 = '$N_pix2',
pix3 = '$N_pix3',
pix4 = '$N_pix4',
pix5 = '$N_pix5'
WHERE ad_ref = '$A_ref' ";
mysql_query($sql)
or die("could not execute HOMES UPDATE PICTURES query");
/*
* Update the client table
*/
ETC ETC
} // end BIG else
?>
[/code]
[code=php]
<?php
/*
* a_picts.php
*
* Called by : homes_add.php
*
* calls a_picts_fm.php
*
* Gets pictures for the advert and checks them out
*/
if(isset($_POST['run'])){ // BIG IF
$pix1_y = $pix2_y = $pix3_y = $pix4_y = $pix5_y = "n";
$A_ref = strip_tags(trim($_POST["adref"]));
$N_pix1 = strip_tags(trim($_FILES['upLoad1'][name]));
$N_pix2 = strip_tags(trim($_FILES['upLoad2'][name]));
$N_pix3 = strip_tags(trim($_FILES['upLoad3'][name]));
$N_pix4 = strip_tags(trim($_FILES['upLoad4'][name]));
$N_pix5 = strip_tags(trim($_FILES['upLoad5'][name]));
$ctr = 0;
// Checking image in pix files.
if($N_pix1 != ""){
if($_FILES['upLoad1']['tmp_name'] == "none") {
$message1 = "Picture file 1 did not successfully upload" ;
$message2 = "Check the file size. Must be less than 500K";
require_once ("a_picts_fm.php");
exit();
} // endif
if(!ereg("image",$_FILES['upLoad1']['type'])) {
$message1 = "The file you have selected for Picture 1 is not";
$message2 = "a recognised picture file - Please try a different file";
require_once ("a_picts_fm.php");
exit();
} // endif
$pix1_y = "y";
} // endif
else{
$N_pix1 = "none";
} // end else
if($N_pix2 != ""){
if($_FILES['upLoad2']['tmp_name'] == "none") {
$message1 = "Picture file 2 did not successfully upload" ;
$message2 = "Check the file size. Must be less than 500K";
require_once ("a_picts_fm.php");
exit();
} // endif
if(!ereg("image",$_FILES['upLoad2']['type'])) {
$message1 = "The file you have selected for Picture 2 is not";
$message2 = "a recognised picture file - Please try a different file";
require_once ("a_picts_fm.php");
exit();
} // endif
$pix2_y = "y";
} // endif
else{
$N_pix2 = "none";
} // end else
if($N_pix3 != ""){
if($_FILES['upLoad3']['tmp_name'] == "none") {
$message1 = "Picture file 3 did not successfully upload" ;
$message2 = "Check the file size. Must be less than 500K";
require_once ("a_picts_fm.php");
exit();
} // endif
if(!ereg("image",$_FILES['upLoad3']['type'])) {
$message1 = "The file you have selected for Picture 3 is not";
$message2 = "a recognised picture file - Please try a different file";
require_once ("a_picts_fm.php");
exit();
} // endif
$pix3_y = "y";
} // endif
else{
$N_pix3 = "none";
} // end else
if($N_pix4 != ""){
if($_FILES['upLoad4']['tmp_name'] == "none") {
$message1 = "Picture file 4 did not successfully upload" ;
$message2 = "Check the file size. Must be less than 500K";
require_once ("a_picts_fm.php");
exit();
} // endif
if(!ereg("image",$_FILES['upLoad4']['type'])) {
$message1 = "Picture file did not successfully upload: Pix 4" ;
$message2 = "a recognised picture file - Please try a different file";
require_once ("a_picts_fm.php");
exit();
} // endif
$pix4_y = "y";
} // endif
else{
$N_pix4 = "none";
} // end else
if($N_pix5 != ""){
if($_FILES['upLoad5']['tmp_name'] == "none") {
$message1 = "Picture file 5 did not successfully upload" ;
$message2 = "Check the file size. Must be less than 500K";
require_once ("a_picts_fm.php");
exit();
} // endif
if(!ereg("image",$_FILES['upLoad5']['type'])) {
$message1 = "The file you have selected for Picture 5 is not";
$message2 = "a recognised picture file - Please try a different file";
require_once ("a_picts_fm.php");
exit();
} // endif
$pix5_y = "y";
} // endif
else{
$N_pix5 = "none";
} // end else
/*
* Everything seems ok - so we connect to the database and
* move the images to the website.
*/
if($pix1_y == "y"){
$destination = 'D:WebDWimages'."\".$_FILES['upLoad1']['name'];
$temp_file = $_FILES['upLoad1']['tmp_name'];
move_uploaded_file($temp_file,$destination);
} // endif
if($pix2_y == "y"){
$destination = 'D:WebDWimages'."\".$_FILES['upLoad2']['name'];
$temp_file = $_FILES['upLoad2']['tmp_name'];
move_uploaded_file($temp_file,$destination);
} // endif
if($pix3_y == "y"){
$destination = 'D:WebDWimages'."\".$_FILES['upLoad3']['name'];
$temp_file = $_FILES['upLoad3']['tmp_name'];
move_uploaded_file($temp_file,$destination);
} // endif
if($pix4_y == "y"){
$destination = 'D:WebDWimages'."\".$_FILES['upLoad4']['name'];
$temp_file = $_FILES['upLoad4']['tmp_name'];
move_uploaded_file($temp_file,$destination);
} // endif
if($pix5_y == "y"){
$destination = 'D:WebDWimages'."\".$_FILES['upLoad5']['name'];
$temp_file = $_FILES['upLoad5']['tmp_name'];
move_uploaded_file($temp_file,$destination);
} // endif
echo "got here";
} // end BIG IF
else {
$message1 = "none";
$message2 = "none";
require_once ("a_picts_fm.php");
exit();
} // end else
echo " *** and got here"; // THIS WHERE IT STOPS
?>
[/code]
[code=php]
<?php
/*
* picts_fm.php
*
* Called by : picts.php
* IT THEN GOES BACK TO PICTS.PHP
*
* FORM for adding images.
*
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
var IE = true;
if (navigator.appName != "Microsoft Internet Explorer"){IE = false}
function showImg1(){
var fullName = document.main_fm.upLoad1.value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
if (IE)
{
document.getElementById('image1').style.display = '';
document.getElementById('image1').src = fullName;
}
document.main_fm.fName1.value = 'Picture file name: '+fileName;
}
else {
alert('Invalid file type');
}
}
</script>
</head>
<body>
<!-- Using a linked stylesheet -->
<link rel="STYLESHEET" type="text/css" href="yodbod.css">
<img alt="header (13K)" src="flashtest1.jpg" height="130" width="920" />
<div style='width:600px; position:absolute; left:40px; top:160px' >
<b><big>Adding pictures to your advert.</big></b><br>
<b>Select your picture files from your computer using the browse buttons.</b><br />
You can have up to five photos for all catagories except Jobs and Careers<br />
which excepts only one (we couldn't see any reason for more!).<br />
<br />
<?php
if($message1 != "none"){
echo "$message1<br />$message2";
} // end if
?>
</div>
<form name="main_fm" enctype ="multipart/form-data" action="a_picts.php" method="POST">
<input type = 'hidden' name='run' value="on">
<input type="hidden" name ="MAX FILE SIZE" value="500000">
<input type = 'hidden' name='adref' value="<?php echo $A_ref ?>">
<div style='position:absolute; left:40px; top:320px' >
<b>First image:</b><br />
<input type="file" size="50" id = "u1" name="upLoad1" onchange="showImg1()"><br />
<input type="text" size="50" id = "n1" name="fName1" readonly>
<input type="button" value ="Clear" onclick="document.main_fm.upLoad1.value='';document.main_fm.fName1.value='';document.getElementById('image1').src='';document.getElementById('image1').style.display='none'">
</div>
<div style='position:absolute; left:500px; top:262px' >
<img height='160' width='160' id="image1" style='display:none' />
</div>
<div style='position:absolute; left:370px; top:280px' >
<input type="submit" value="Upload All Images"><br />
<input type="reset" value="Reset All Images"
onclick="
document.getElementById('image1').src='';document.getElementById('image1').style.display='none'
document.getElementById('image2').src='';document.getElementById('image2').style.display='none'
document.getElementById('image3').src='';document.getElementById('image3').style.display='none'
document.getElementById('image4').src='';document.getElementById('image4').style.display='none'
document.getElementById('image5').src='';document.getElementById('image5').style.display='none'
">
</div>
</form>
</body>
</html>
[/code]
Not sure if that is the reason ...[/QUOTE]Well your script contains an [I]exit()[/I] and it is impossible to pass that point without the script aborting.
[code=php]
if(isset($_POST['run'])){ // BIG IF
PROCESSES THE PICT_FM.PHP FORM
echo "got here";
} // end BIG IF
else {
$message1 = "none";
$message2 = "none";
require_once ("a_picts_fm.php");
exit();
} // end else
echo " *** and got here"; // THIS WHERE IT STOPS
?> [/code]
[code=php]
<?php
/*
* homes_add.php
*
* Called by : homes_ad_btn.php
*
* Call a_picts.php to get the pictures
*
* processes the homes_add_fm.php which is the
* FORM for adding a home.
*/
if (!isset($_POST['run_mn'])){
PREPARES DATA AND CALLS THE MAIN FORM ( NOT PICTURE FORM)
else { // BIG else - SO MAIN FORM HAS RUN
VALIDATES FORM DATA
/*
* Now we get the pictures.
*/
if( $pict == "y"){
require_once("a_picts.php"); // < -- HERE IS THE CALLING
exit(); // < -- I TRIES TAKING THIS OUT
} // endif
else{
$N_pix1=$N_pix2=$N_pix3=$N_pix4=$N_pix5="none";
} // end else
// I WANT TO RETURN BACK HERE
$sql = "UPDATE homes SET
pix1 = '$N_pix1',
pix2 = '$N_pix2',
pix3 = '$N_pix3',
pix4 = '$N_pix4',
pix5 = '$N_pix5'
WHERE ad_ref = '$A_ref' ";
mysql_query($sql)
or die("could not execute HOMES UPDATE PICTURES query");
/*
* Update the client table
*/
ETC ETC
} // end BIG else
?> [/code]
[code=php]if(isset($_POST['run'])){ // BIG IF
PROCESSES THE PICT_FM.PHP FORM
echo "got here";
} // end BIG IF
else {
$message1 = "none";
$message2 = "none";
require_once ("a_picts_fm.php"); // CALLS THE FORM
exit();
} // end else
echo " *** and got here"; // THIS WHERE IT STOPS
?> [/code]
[code=php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
var IE = true;
if (navigator.appName != "Microsoft Internet Explorer"){IE = false}
function showImg1(){
var fullName = document.main_fm.upLoad1.value;
var fileName = fullName.match(/[^/\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg')
{
if (IE)
{
document.getElementById('image1').style.display = '';
document.getElementById('image1').src = fullName;
}
document.main_fm.fName1.value = 'Picture file name: '+fileName;
}
else {
alert('Invalid file type');
}
}
</script>
</head>
<body>
<!-- Using a linked stylesheet -->
<link rel="STYLESHEET" type="text/css" href="yodbod.css">
<img alt="header (13K)" src="flashtest1.jpg" height="130" width="920" />
<div style='width:600px; position:absolute; left:40px; top:160px' >
<b><big>Adding pictures to your advert.</big></b><br>
<b>Select your picture files from your computer using the browse buttons.</b><br />
You can have up to five photos for all catagories except Jobs and Careers<br />
which excepts only one (we couldn't see any reason for more!).<br />
<br />
<?php
if($message1 != "none"){
echo "$message1<br />$message2";
} // end if
?>
</div>
<form name="main_fm" enctype ="multipart/form-data" action="a_picts.php" method="POST">
<input type = 'hidden' name='run' value="on">
<input type="hidden" name ="MAX FILE SIZE" value="500000">
<input type = 'hidden' name='adref' value="<?php echo $A_ref ?>">
<div style='position:absolute; left:40px; top:320px' >
<b>First image:</b><br />
<input type="file" size="50" id = "u1" name="upLoad1" onchange="showImg1()"><br />
<input type="text" size="50" id = "n1" name="fName1" readonly>
<input type="button" value ="Clear" onclick="document.main_fm.upLoad1.value='';document.main_fm.fName1.value='';document.getElementById('image1') .src='';document.getElementById('image1').style.display='none'">
</div>
<div style='position:absolute; left:500px; top:262px' >
<img height='160' width='160' id="image1" style='display:none' />
</div> [/code]
0.1.9 — BETA 5.9