Sim Posted March 16, 2012 Share Posted March 16, 2012 i cant seem to find this error, been looking over this code for hours... ;\ <?php session_start(); if($_SESSION['user']['level'] < 5) { echo 'not allowed...'; } else { echo 'test'; if(isset($_POST['submitForm'])) { //check for errors (dont know why) if(empty($_POST['textName'])) { $msg = "Name was left blank...<br>"; } if(empty($_POST['textDesc'])) { $msg .= "Description was left blank..."; } //if no errors if(empty($msg)) { addItem(); } } echo 'here'; echo $msg; ?> <form name="form1" action="" method="post" enctype="multipart/form-data"> <table width="100%" border="0"> <tr> <td><strong>Thumbnail:</strong></td> <td><input type="file" name="fileThumb" /></td> <tr> <tr> <td><strong>Name:</strong></td> <td><input type="text" name="textName" value="<?= $name ?>></td> <tr> <tr> <td><strong>Type:</strong></td> <td><select name="selectType"> <option value="1">Equipable</option> <option value="2">Token</option> <option value="3">Breeding</option> <option value="4">Quest</option> </select> </td> <tr> <tr> <td><strong>Searchable:</strong></td> <td><select name="selectSearch"> <option value="1">Yes</option> <option value="0">No</option> </select> </td> <tr> <tr> <td><strong>Description:</strong></td> <td><textarea name="textDesc" rows="4"><?= $desc ?></textarea></td> <tr> <tr> <td><strong>If Item equipable (file that goes in imagegen/1/):</strong></td> <td><input type="file" name="fileItem1" /></td> <tr> <tr> <td><strong>If Item equipable (file that goes in imagegen/2/):</strong></td> <td><input type="file" name="fileItem2" /></td> <tr> <tr> <td><strong>If Item equipable (file that goes in imagegen/3/):</strong></td> <td><input type="file" name="fileItem3" /></td> <tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><input name="submitForm" type="submit" id="submitForm" value="Add Item"></td> </tr> </table> </form> <? } function imageUpload($file, $path, $name) { //vars $imageinfo = getimagesize($file['file']['tmp_name']); list($width, $height) = getimagesize($file['file']['tmp_name']); $userid = $_SESSION['userID']; $file_typ = array(); $file_typ = explode('.',strtolower($file["file"]["name"])); $file_type = "." . $file_typ[count($file_typ)-1]; echo $file["file"]["name"]; //only allow jpg, png, gif if( ($file_type == ".jpg" || $file_type == ".png" || $file_type == ".gif") && ($imageinfo['mime'] == "image/jpg" || $imageinfo['mime'] == "image/jpeg" || $imageinfo['mime'] == "image/png" || $imageinfo['mime'] == "image/gif") && isset($imageinfo) ) { if(move_uploaded_file($file["file"]["tmp_name"],$path . $name . $file_type)) { return true; } else { return false; } } } function addItem() { //secure input into database, never know who may gain admin access then screw your db up =) $name = mysql_real_escape_string($_POST['textName']); $desc = mysql_real_escape_string($_POST['textDesc']); $type = mysql_real_escape_string($_POST['selectType']); $search = mysql_real_escape_string($_POST['selectSearch']); $namer = strtolower(str_replace(" ", '', $name)); echo $namer; //upload thumb, return filename $img_name = imageUpload($_FILES["fileThumb"], "static/items/", $namer); //upload items, check if errored if(imageUpload($_FILES['fileItem1'], "static/imagegen/1/", $namer) == false) $msg = "Upload Image items/1/ failed...<br>"; if(imageUpload($_FILES['fileItem2'], "static/imagegen/2/", $namer) == false) $msg .= "Upload Image items/2/ failed...<br>"; if(imageUpload($_FILES['fileItem3'], "static/imagegen/3/", $namer) == false) $msg .= "Upload Image items/3/ failed...<br>"; //no errors if(empty($msg)) { //insert item } else { echo 'testtt'; } } ?> Quote Link to comment Share on other sites More sharing options...
Sim Posted March 16, 2012 Author Share Posted March 16, 2012 Is the only thing changed the echos Quote Link to comment Share on other sites More sharing options...
Sim Posted March 17, 2012 Author Share Posted March 17, 2012 now its saying unexpected end line 1... Quote Link to comment Share on other sites More sharing options...
Sim Posted March 17, 2012 Author Share Posted March 17, 2012 update. errors removed when I removed the //comments... WTF is up with that? It doesn't pinpoint the actual line of the error, always saying line 1.. Quote Link to comment Share on other sites More sharing options...
Uridium Posted March 17, 2012 Share Posted March 17, 2012 SIM are you working offline with this or on a server ? if your working on a server Download the suspect file to a new place copy all the TEXT from it open windows notepad and see if the layout of the code is fine.. If the layout is all on line 1 then your file is corrupt and will need resetting out example spacing and breaks... Quote Link to comment Share on other sites More sharing options...
Uridium Posted March 17, 2012 Share Posted March 17, 2012 heres a prime example... <?phpsession_start();if($_SESSION['user']['level'] < 5){ echo 'not allowed...';}else{ echo 'test'; if(isset($_POST['submitForm'])) { //check for errors (dont know why) if(empty($_POST['textName'])) { $msg = "Name was left blank..."; } if(empty($_POST['textDesc'])) { $msg .= "Description was left blank..."; } //if no errors if(empty($msg)) { addItem(); } } echo 'here'; echo $msg;?><form name="form1" action="" method="post" enctype="multipart/form-data"><table width="100%" border="0"> <tr> <td><strong>Thumbnail:</strong></td> <td><input type="file" name="fileThumb" /></td> </tr> <tr> <td><strong>Name:</strong></td> <td><input type="text" name="textName" value="<? echo $name; ?>"></td> </tr> <tr> <td><strong>Type:</strong></td> <td> <select name="selectType"> <option value="1">Equipable</option> <option value="2">Token</option> <option value="3">Breeding</option> <option value="4">Quest</option> </select> </td> </tr> <tr> <td><strong>Searchable:</strong></td> <td> <select name="selectSearch"> <option value="1">Yes</option> <option value="0">No</option> </select> </td> </tr> <tr> <td><strong>Description:</strong></td> <td><textarea name="textDesc" rows="4"><? echo $desc; ?></textarea></td> </tr> <tr> <td><strong>If Item equipable (file that goes in imagegen/1/):</strong></td> <td><input type="file" name="fileItem1" /></td> </tr> <tr> <td><strong>If Item equipable (file that goes in imagegen/2/):</strong></td> <td><input type="file" name="fileItem2" /></td> </tr> <tr> <td><strong>If Item equipable (file that goes in imagegen/3/):</strong></td> <td><input type="file" name="fileItem3" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><input name="submitForm" type="submit" id="submitForm" value="Add Item"></td> </tr></table></form><?} function imageUpload($file, $path, $name){ $imageinfo = getimagesize($file['file']['tmp_name']); list($width, $height) = getimagesize($file['file']['tmp_name']); $userid = $_SESSION['userID']; $file_typ = array(); $file_typ = explode('.',strtolower($file["file"]["name"])); $file_type = "." . $file_typ[count($file_typ)-1]; echo $file["file"]["name"]; //only allow jpg, png, gif if((($file_type == ".jpg") || ($file_type == ".png") || ($file_type == ".gif")) && (($imageinfo['mime'] == "image/jpg") || ($imageinfo['mime'] == "image/jpeg") || ($imageinfo['mime'] == "image/png") || ($imageinfo['mime'] == "image/gif")) && isset($imageinfo)) { if(move_uploaded_file($file["file"]["tmp_name"],$path . $name . $file_type)) { return true; } else { return false; } }}function addItem(){ //secure input into database, never know who may gain admin access then screw your db up =) $name = mysql_real_escape_string($_POST['textName']); $desc = mysql_real_escape_string($_POST['textDesc']); $type = mysql_real_escape_string($_POST['selectType']); $search = mysql_real_escape_string($_POST['selectSearch']); $namer = strtolower(str_replace(" ", '', $name)); echo $namer; $img_name = imageUpload($_FILES["fileThumb"], "static/items/", $namer); if(imageUpload($_FILES['fileItem1'], "static/imagegen/1/", $namer) == false) { $msg = "Upload Image items/1/ failed..."; } if(imageUpload($_FILES['fileItem2'], "static/imagegen/2/", $namer) == false) { $msg .= "Upload Image items/2/ failed..."; } if(imageUpload($_FILES['fileItem3'], "static/imagegen/3/", $namer) == false) { $msg .= "Upload Image items/3/ failed..."; } if(empty($msg)) { //insert item } else { echo 'testtt'; }} Quote Link to comment Share on other sites More sharing options...
Sim Posted March 18, 2012 Author Share Posted March 18, 2012 THats exactly what it is doing? I don't feel like retyping this whole file. I done did it a few times. I think its notepadd++ doing this. not my actuall FTP client (filezilla) The weird thing, its always this same file. I"ll delete it and create same one by retyping it in notepad, no copy paist and same outcome happens sooner or later. ALl my other files generated are fine. doesn't make much sense.. but it sucks... I spent over 5 hours on this file that should of only taken me 30 minutes. ;\ Quote Link to comment Share on other sites More sharing options...
Djkanna Posted March 18, 2012 Share Posted March 18, 2012 THats exactly what it is doing? I don't feel like retyping this whole file. I done did it a few times. I think its notepadd++ doing this. not my actuall FTP client (filezilla) The weird thing, its always this same file. I"ll delete it and create same one by retyping it in notepad, no copy paist and same outcome happens sooner or later. ALl my other files generated are fine. doesn't make much sense.. but it sucks... I spent over 5 hours on this file that should of only taken me 30 minutes. ;\ Manually set the transfer type? (Filezilla's settings) sorted screw ups for me. Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted March 19, 2012 Share Posted March 19, 2012 (edited) edit :nevermind... what i thought was not it lol Your php open and closing tags i thought was the problem, but may be wrong... this part does stick out in the input area when i test that script on my test hosting other then this there is no error ></td> <tr> <tr> <td><strong>Type:</strong></td> <td><select name= Edited March 19, 2012 by lucky3809 Quote Link to comment Share on other sites More sharing options...
Sim Posted March 20, 2012 Author Share Posted March 20, 2012 The prob was notepad++. It worked with dreamweaver though Quote Link to comment Share on other sites More sharing options...
Uridium Posted March 20, 2012 Share Posted March 20, 2012 Yeah i seem to be having same issue with notepad++ did mention it on their boards but they never got back to me. Quote Link to comment Share on other sites More sharing options...
Sim Posted March 20, 2012 Author Share Posted March 20, 2012 All I did was copy the code from notepad++ to dreamweaver then save and it worked... Didn't make much sense. I spent all those hours.. Quote Link to comment Share on other sites More sharing options...
prototype Posted March 20, 2012 Share Posted March 20, 2012 thread removed Quote Link to comment Share on other sites More sharing options...
Spudinski Posted March 20, 2012 Share Posted March 20, 2012 The PHP interpreter doesn't parse white space, it won't matter anyhow. The only exception is heredoc blocks. On another note, *nix uses different line endings than Windows. From Windows to *nix shouldn't render text malformed, but visa versa will. Another thing you can do is use long comments, i.e. /* ... */ 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.