Jump to content
MakeWebGames

parse error, unexpected $end line 6...


Sim

Recommended Posts

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';
}
}
?>
Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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';    }}
Link to comment
Share on other sites

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. ;\

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by lucky3809
Link to comment
Share on other sites

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. /* ... */

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...