hellonoko Posted February 23, 2007 Share Posted February 23, 2007 my php page is suddenly displaying half code half what it should display. I made a few minor changes to the code but nothing really. Running this off of WAMP. Not getting any errors. What causes this? "; echo ""; echo "Name: ".$_FILES['imagefile']['name'].""; echo " "; echo "Size: ".$_FILES['imagefile']['size'].""; echo " "; echo "Type: ".$_FILES['imagefile']['type'].""; echo " "; echo "Copy Done...."; } else { echo " "; echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].") "; } } // echo " "; // $image_to_thumbnail = $_FILES['imagefile']['name']; // echo $image_to_thumbnail; //include "resize_image.php"; ?> Acctual code: <?php include "admin_menu.php"; ?> <title>Upload Image</title><form name="form1" method="post" action="" enctype="multipart/form-data"> <input name="imagefile" type="file" size="100"> <input type="submit" name="Submit" value="Upload"> <? if(isset( $Submit )) { //If the Submitbutton was pressed do: if ($_FILES['imagefile']['type'] == "image/jpeg") { copy ($_FILES['imagefile']['tmp_name'], "../images/full/".$_FILES['imagefile']['name']) or die ("Could not copy"); echo "<br><br>"; echo ""; echo "<b>Name: </b>".$_FILES['imagefile']['name'].""; echo "<br>"; echo "<b>Size: </b>".$_FILES['imagefile']['size'].""; echo "<br>"; echo "<b>Type: </b>".$_FILES['imagefile']['type'].""; echo "<br><br>"; echo "<b>Copy Done....</b>"; } else { echo "<br><br>"; echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>"; } } // echo "<br><br>"; // $image_to_thumbnail = $_FILES['imagefile']['name']; // echo $image_to_thumbnail; //include "resize_image.php"; ?> </form> Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 23, 2007 Share Posted February 23, 2007 try changing from this: <? if(isset( $Submit )) { to this: <?php if(isset( $Submit )) { i think its your opening php tag Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 23, 2007 Author Share Posted February 23, 2007 Well that fixed it. Spitting out code on the page. But now the page is broken and does not function. -Ian Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 23, 2007 Share Posted February 23, 2007 You /your host have short tags turned off. Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 23, 2007 Author Share Posted February 23, 2007 Turned on 'short open tag' Assume that it? Still no luck. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 How did you do so? Also, is it your computer or a shared host? Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 24, 2007 Author Share Posted February 24, 2007 I turned them on in the WAMP menu. It is my computer but at the same time I am trying code once it works on my host. 1and1. Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 what is $submit? You have to post more code so we can locate the problem...ur giving us half the info Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 24, 2007 Author Share Posted February 24, 2007 $submit ? A submit button? I posted full code of the page in my first post. <input type="submit" name="Submit" value="Upload"> <?php if(isset( $Submit )) { //If the Submitbutton was pressed do: Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 Is the problem still that the code is displaying, or that the code is not working? Use the <?php tag. Edit: That is not how to properly access a variable. If the form's method is post, you need to do $submit = $_POST['submit']; before using it. Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 24, 2007 Author Share Posted February 24, 2007 The problem is that the code was working perfectly. Then suddenly started displaying code on page. And then when I added in the full <?php tag stopped displaying but stopped working. This is on both my machine and my host. I will add the proper POST in. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 Also add this to the very top: ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 24, 2007 Author Share Posted February 24, 2007 Returns: Parse error: parse error, unexpected T_IF in C:\www\artbytoni.com\admin\upload_image.php on line 21 After adding: <?php $submit = $_POST['submit'] if(isset( $submit )) { //If the Submitbutton was pressed do: And the error reporting. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 So there's an unexpected if...because something very important is missing from the line above it; Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 check all of your { } you need to make sure you open and close these or you will get that error, i see that you did not close your first IF function but you closed the second one I take that back you did, but try moving them around thats the only reason you would get that error...because if the IF statement is false you definitely wouldn't get that error Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 ... Quote Link to comment Share on other sites More sharing options...
hellonoko Posted February 24, 2007 Author Share Posted February 24, 2007 I am not sure what your pointing out here Archadian? echo "<br><br>"; echo ""; echo "<b>Name: </b>".$_FILES['imagefile']['name'].""; echo "<br>"; echo "<b>Size: </b>".$_FILES['imagefile']['size'].""; echo "<br>"; echo "<b>Type: </b>".$_FILES['imagefile']['type'].""; echo "<br><br>"; echo "<b>Copy Done....</b>"; The problem is that my code was working. And then for no reason it stopped working. When i added the code at the bottom of the page that is commented out. Jessi: I may just go for a restart and reinstall of WAMP Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 make sure your file_uploads is set to on in your php.ini file, if its not then the upload won't work Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.