Jump to content

whats this error?


shujjah

Recommended Posts

Yeah, that's the idea. About the only thing not covered in the references on php.net is renaming the file if it already exists. To do that, you would need a loop like this:

$destination = "/path/to/upload/dir/";$uploaded_file = $_FILES['uploaded_file'];$filename = $uploaded_file['name'];$nr = 0;while (file_exists($destination . $filename)){  $filename = ++$nr . "_" . $uploaded_file['name'];}move_uploaded_file($uploaded_file['tmp_name'], $destination . $filename);

Link to comment
Share on other sites

  • Replies 153
  • Created
  • Last Reply

ok one last question before i start on the first script. and that is about the time so when someone clicks ok submit in the form processsing script there will be this code to save the time

$date = time(m/d/y);echo make_datestr(time());

and then i will save $date it in the database?

Link to comment
Share on other sites

yes you save that variable to the database. If you are using MySql you will probably want to save it as a DateTime field that way you can do comparisions, etc on those fields later on if you need to. If you know you will never need to process the dates you could store it as a varchar

Link to comment
Share on other sites

again prob with the form this is the form

<body>		 <form action="addr.php" method="post">Title:<input type="text" name="title" size="40" maxlength="200"><br> Content:<textarea name="body" cols="50" rows="15"> </textarea> <br>Platform:<select name="platform">	<option value="Xbox360"> Xbox360</option>	<option value="PS3"> PS3</option>	<option value="PC"> PC</option></select>					  <br>	Genre:<select name="genre">	<option value="Racing"> Racing</option>	<option value="Action"> Action</option>	<option value="Adventure"> Adventure</option>	<option value="Sports"> Sports</option></select>					  <br>			<b>Rating</b>	<br>  Gameplay:<select name="gameplay">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>			  <br>Graphics:<select name="graphics">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>		  <br>Sound:<select name="sound">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>			<br>Multiplayer:<select name="multiplayer">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>		  <br>				<form method="post" action="addr.php" enctype="multipart/form-data">Image:<input type="file" name="imagefile"><input type="submit" name="Submit" value="Submit">	   </form></body></html>

now the prob is that image upload field needs another form so how to make these two form one simple and one for the image one into one form so that when a user clicks submit all of the info including the image is send to addr.php?so what shud i do now? how do do this?

Link to comment
Share on other sites

ok heres the html form called adr.html

<html><head>  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">  <title>Gamerz Galore Add A Review</title>  <meta name="description" content="">  <meta name="keywords" content="">  <meta name="author" content="Unregistered User">  <meta name="generator" content="AceHTML Freeware"><link rel="stylesheet" type="text/css" href="add.css"></head><body><center><div id="body"><form action="addr.php" method="post" enctype="multipart/form-data">Game Name: <input type="text" name="title" size="40" maxlength="200"><br>Content:  <textarea name="body" cols="50" rows="15"> </textarea> <br>Platform:  <select name="platform">	<option value="Xbox360"> Xbox360</option>	<option value="PS3"> PS3</option>	<option value="PC"> PC</option></select>	 			<br>	<tr><td>Genre:<select name="genre">	<option value="Racing"> Racing</option>	<option value="Action"> Action</option>	<option value="Adventure"> Adventure</option>	<option value="Sports"> Sports</option></select>					  <br>			<b>Rating</b>	<br>  Gameplay:  <select name="gameplay">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>			  <br>Graphics:<select name="graphics">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>		  <br>Sound:<select name="sound">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>			<br>Multiplayer:<select name="multiplayer">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>		  <br>		Image:<input type="file" name="image_file"><br><br><br><br><input type="submit" name="Submit" value="Submit">	   </form></div></center></body></html>

and this is the addr.php ( finally done after some here and there )

<?phprequire"db_connect.php";$title = mysql_real_escape_string($_POST['title']);$body = mysql_real_escape_string($_POST['body']);$platform = mysql_real_escape_string($_POST['platform']);$genre = mysql_real_escape_string($_POST['genre']);$gameplay = mysql_real_escape_string($_POST['gameplay']);$graphics = mysql_real_escape_string($_POST['graphics']);$sound = mysql_real_escape_string($_POST['sound']);$multiplayer = mysql_real_escape_string($_POST['multiplayer']);$path = "/uimages/"; $maxSize = "100000"; $maxWidth = "130"; $maxHeight = "150"; $allowedExt = ".gif,.bmp,.png,.jpg"; $imagename = "$up_path.$file_name"	 function get_ext($file){ 	  $ex = strstr($file,"."); 	  return $ex; 	} 	 	/* 	  Here we are creating a function to get the extention of a file. 		We then create a variable that uses the 'strstr' function. 		strstr = Find first occurrence of a string, says php.net/strstr 		We then call the $file variable up and then add a object to look for. 		In this case, it is the "." (period). 		We then return the variable 	*/ if($submit){		 $file = $_FILES['image_file']; 		 		/* 		  So the submit button was pressed. 			We then create a variable and call the file using $_FILES['INPUT_NAME_HERE']; 		*/ 		 		if($file == NULL){ 		  echo "No image selected."; 			/* If no file was selected, echo the error. */ 		}else{ 					  			$file_name = $_FILES['image_file']['name']; 			$up_path = $path.$file_name; 			$ext = get_ext($file); 			 			list($width, $height, $ftype, $attr) = getimagesize($_FILES['image_file']['tmp_name']); 			$fileExt = explode(",",$allowedExt); 			 			/* List = Assign variables as if they were an array - php.net/list  			  so we are assigning 4 different variables, width, height, file type and attributes 				We will not be using $ftype or $attr, they are merely there to show you. 				 				We are also creating a new variable with the explode function on our allowed file extentions. 			*/ 			 			if ($width > $maxWidth){ 			  echo "The width of the image can only be: ".$maxWidth."px"; 			}elseif ($height > $maxHeight){ 			  echo "The height of the image can only be: ".$maxHeight."px"; 				/* We did a check to see if the width and height are the correct sizes. */ 			}elseif (!in_array($ext,$fileExt)){ 			  echo "File extention not recognized.<br /> Allowed extentions: ".$allowedExt; 				/* We check if the extention of the file is in the array we made. */ 			}else{ 			  if(move_uploaded_file($file_name,$up_path)){ 				  echo "Image: '".$file_name."' has successfully beed uploaded to: '".$path."'"; 					/* If the file was moved to the folder, we echo the message and move the file */ 				}else{ 					echo "Error with uploading the image."; 					/* 					  If the file was not moved, echo the error 					  This could be because the path specified was incorrect or the folder was not CHMOD'ed correctly 					*/ 				} 			  if(!$title){  //this means If the title is really empty.					 echo "Error: Game Name is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$body){  //this means If the title is really empty.					 echo "Error:Main review body is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$platform){  //this means If the title is really empty.					 echo "Error:Game Platform is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$genre){  //this means If the title is really empty.					 echo "Error:Game Genre is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$gameplay){  //this means If the title is really empty.					 echo "Error:Gameplay rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$graphics){  //this means If the title is really empty.					 echo "Error:Graphics rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$sound){  //this means If the title is really empty.					 echo "Error:Sound rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$multiplayer){  //this means If the title is really empty.					 echo "Error:Multiplayer rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  else {$author = mysql_query("SELECT username FROM `users` Where id="' . $_SESSION['id'] . '"'")$auth = @mysql_fetch_assoc($author)$rauthor = $auth$date = time();echo make_datestr(time());$result = mysql_query("INSERT INTO reviews (title, body, author, date_added, platform, genre, gameplay, graphics, sound, multiplayer, picture)					   VALUES ('$title','$body','$rauthor','$date','$platform','$genre','$gameplay','$graphics','$sound','$multiplayer','$imagename')";echo "<b>Thank you! Review added Successfully!<br>Your review will be on display after being approved by our editors.<br>You'll be redirected to Home Page after (4) Seconds";		  echo "<meta http-equiv=Refresh content=4;url=index.php>"; } }else{echo "No form was submitted"}?>

but i get this error Parse error: syntax error, unexpected T_FUNCTION in D:\xampp\htdocs\addr.php on line 17and now that you have seen my code do u think its godo enough to use and is there a need to improve it and how?and one more thing i have a overall field in my reviews table that is basically the overall ratingso overall will be basically this (gameplay + graphics + sound + multipalyer) divided by 4so this will basically give me that average rating and i will save that in $overall and will add that to the databse so how to do this?and also is the image function upload correct and is the value that i am storing in the databse $imagename = "$up_path.$file_name" the correct valure to store? please help .

Link to comment
Share on other sites

replace this line

$author = mysql_query("SELECT username FROM `users` Where id="' . $_SESSION['id'] . '"'")

with this

$author = mysql_query("SELECT username FROM `users` Where id=' " . $_SESSION['id'] . " ' " );

also you have a lot of semicolons missing, from line #109

$auth = @mysql_fetch_assoc($author)$rauthor = $auth$author = mysql_query("SELECT username FROM `users` Where id=' " . $_SESSION['id'] . " ' " )

Link to comment
Share on other sites

ok thnkx now i get this Parse error: syntax error, unexpected T_ELSE in D:\xampp\htdocs\addr.php on line 123althought i dont think there is any extra } in the end of the script? and plz someone answer my questions on my second last post also plz

Link to comment
Share on other sites

ok thnkx now i get this Parse error: syntax error, unexpected T_ELSE in D:\xampp\htdocs\addr.php on line 123althought i dont think there is any extra } in the end of the script? and plz someone answer my questions on my second last post also plz
I don't know if this is correct (what I will write)...You can't have an else statement if you don't have an if statement...// Lets snap to the end part, ok?
 }			  elseif(!$multiplayer){  //this means If the title is really empty.					 echo "Error:Multiplayer rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  else {$author = mysql_query("SELECT username FROM `users` Where id="' . $_SESSION['id'] . '"'")$auth = @mysql_fetch_assoc($author)$rauthor = $auth$date = time();echo make_datestr(time());$result = mysql_query("INSERT INTO reviews (title, body, author, date_added, platform, genre, gameplay, graphics, sound, multiplayer, picture)					   VALUES ('$title','$body','$rauthor','$date','$platform','$genre','$gameplay','$graphics','$sound','$multiplayer','$imagename')";echo "<b>Thank you! Review added Successfully!<br>Your review will be on display after being approved by our editors.<br>You'll be redirected to Home Page after (4) Seconds";		  echo "<meta http-equiv=Refresh content=4;url=index.php>";}}else{echo "No form was submitted"}?>

You have if ($width > $maxWidth){ then you have many elseif and then you have the first else statement, and then at the end you have another one. You can't have an else without if.And if that wasn't correct, I don't think you can have 2 else statements like this:

if ($width > $maxWidth){			  echo "The width of the image can only be: ".$maxWidth."px";			}elseif ($height > $maxHeight){			  echo "The height of the image can only be: ".$maxHeight."px";				/* We did a check to see if the width and height are the correct sizes. */			}elseif (!in_array($ext,$fileExt)){			  echo "File extention not recognized.<br /> Allowed extentions: ".$allowedExt;				/* We check if the extention of the file is in the array we made. */			}else{			  if(move_uploaded_file($file_name,$up_path)){				  echo "Image: '".$file_name."' has successfully beed uploaded to: '".$path."'";					/* If the file was moved to the folder, we echo the message and move the file */				}else{					echo "Error with uploading the image.";					/*					  If the file was not moved, echo the error					  This could be because the path specified was incorrect or the folder was not CHMOD'ed correctly					*/				}

Link to comment
Share on other sites

plz can u kindly tell me how to solve thisi simply got rid of this code

else{					echo "Error with uploading the image.";					/*					  If the file was not moved, echo the error					  This could be because the path specified was incorrect or the folder was not CHMOD'ed correctly					*/				}

i will check the path myself instead btu i still get the same error?so plz can someone tell me (code) how to solve this? please?

Link to comment
Share on other sites

<?phprequire"db_connect.php";$title = mysql_real_escape_string($_POST['title']);$body = mysql_real_escape_string($_POST['body']);$platform = mysql_real_escape_string($_POST['platform']);$genre = mysql_real_escape_string($_POST['genre']);$gameplay = mysql_real_escape_string($_POST['gameplay']);$graphics = mysql_real_escape_string($_POST['graphics']);$sound = mysql_real_escape_string($_POST['sound']);$multiplayer = mysql_real_escape_string($_POST['multiplayer']);$path = "/uimages/"; $maxSize = "100000"; $maxWidth = "130"; $maxHeight = "150"; $allowedExt = ".gif,.bmp,.png,.jpg"; $imagename = "$up_path.$file_name";	 function get_ext($file){ 	  $ex = strstr($file,"."); 	  return $ex; 	} 	 	/* 	  Here we are creating a function to get the extention of a file. 		We then create a variable that uses the 'strstr' function. 		strstr = Find first occurrence of a string, says php.net/strstr 		We then call the $file variable up and then add a object to look for. 		In this case, it is the "." (period). 		We then return the variable 	*/ if($submit){		 $file = $_FILES['image_file']; 		 		/* 		  So the submit button was pressed. 			We then create a variable and call the file using $_FILES['INPUT_NAME_HERE']; 		*/ 		 		if($file == NULL){ 		  echo "No image selected."; 			/* If no file was selected, echo the error. */ 		}else{ 					  			$file_name = $_FILES['image_file']['name']; 			$up_path = $path.$file_name; 			$ext = get_ext($file); 			 			list($width, $height, $ftype, $attr) = getimagesize($_FILES['image_file']['tmp_name']); 			$fileExt = explode(",",$allowedExt); 			 			/* List = Assign variables as if they were an array - php.net/list  			  so we are assigning 4 different variables, width, height, file type and attributes 				We will not be using $ftype or $attr, they are merely there to show you. 				 				We are also creating a new variable with the explode function on our allowed file extentions. 			*/ 			 			if ($width > $maxWidth){ 			  echo "The width of the image can only be: ".$maxWidth."px"; 			}elseif ($height > $maxHeight){ 			  echo "The height of the image can only be: ".$maxHeight."px"; 				/* We did a check to see if the width and height are the correct sizes. */ 			}elseif (!in_array($ext,$fileExt)){ 			  echo "File extention not recognized.<br /> Allowed extentions: ".$allowedExt; 				/* We check if the extention of the file is in the array we made. */ 			}else{ 			  if(move_uploaded_file($file_name,$up_path)){ 				  echo "Image: '".$file_name."' has successfully beed uploaded to: '".$path."'"; 					/* If the file was moved to the folder, we echo the message and move the file */ 				}else{ 					echo "Error with uploading the image."; 					/* 					  If the file was not moved, echo the error 					  This could be because the path specified was incorrect or the folder was not CHMOD'ed correctly 					*/ 				} 			  if(!$title){  //this means If the title is really empty.					 echo "Error: Game Name is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$body){  //this means If the title is really empty.					 echo "Error:Main review body is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$platform){  //this means If the title is really empty.					 echo "Error:Game Platform is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$genre){  //this means If the title is really empty.					 echo "Error:Game Genre is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$gameplay){  //this means If the title is really empty.					 echo "Error:Gameplay rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$graphics){  //this means If the title is really empty.					 echo "Error:Graphics rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$sound){  //this means If the title is really empty.					 echo "Error:Sound rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$multiplayer){  //this means If the title is really empty.					 echo "Error:Multiplayer rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  else {$author = mysql_query("SELECT username FROM `users` Where id=' " . $_SESSION['id'] . " ' " );$auth = @mysql_fetch_assoc($author);$rauthor = $auth;$date = time();echo make_datestr(time());$result = mysql_query("INSERT INTO reviews (title, body, author, date_added, platform, genre, gameplay, graphics, sound, multiplayer, picture)					   VALUES ('$title','$body','$rauthor','$date','$platform','$genre','$gameplay','$graphics','$sound','$multiplayer','$imagename')";echo "<b>Thank you! Review added Successfully!<br>Your review will be on display after being approved by our editors.<br>You'll be redirected to Home Page after (4) Seconds";		  echo "<meta http-equiv=Refresh content=4;url=index.php>";} }else{echo "No form was submitted";}?>

since after removing that i still got the same error message so i added it back :)so i just copied the code from here the one i posted the first time and made the changes to i mean added the semicolons etc and now i am getting this arghhh but i have checked the code like thrice and i dont think there is an extra ;Parse error: syntax error, unexpected ';' in D:\xampp\htdocs\addr.php on line 115ah..............

Link to comment
Share on other sites

Sigh... look at lines 114 and 115:

$result = mysql_query("INSERT INTO reviews (title, body, author, date_added, platform, genre, gameplay, graphics, sound, multiplayer, picture)					   VALUES ('$title','$body','$rauthor','$date','$platform','$genre','$gameplay','$graphics','$sound','$multiplayer','$imagename')";

Now, look at the very end. What happened to the closing parenthesis for the mysql_query function? It should be

$result = mysql_query("INSERT INTO reviews (title, body, author, date_added, platform, genre, gameplay, graphics, sound, multiplayer, picture)					   VALUES ('$title','$body','$rauthor','$date','$platform','$genre','$gameplay','$graphics','$sound','$multiplayer','$imagename')");

Link to comment
Share on other sites

ah u are fast i just looked at the script again and found the error and was now going to edit my post but u were i guess fast ::)anyways thnkxso heres the script now

<?phprequire"db_connect.php";$title = mysql_real_escape_string($_POST['title']);$body = mysql_real_escape_string($_POST['body']);$platform = mysql_real_escape_string($_POST['platform']);$genre = mysql_real_escape_string($_POST['genre']);$gameplay = mysql_real_escape_string($_POST['gameplay']);$graphics = mysql_real_escape_string($_POST['graphics']);$sound = mysql_real_escape_string($_POST['sound']);$multiplayer = mysql_real_escape_string($_POST['multiplayer']);$path = "/uimages/"; $maxSize = "100000"; $maxWidth = "130"; $maxHeight = "150"; $allowedExt = ".gif,.bmp,.png,.jpg"; $imagename = "$up_path.$file_name";	 function get_ext($file){ 	  $ex = strstr($file,"."); 	  return $ex; 	} 	 	/* 	  Here we are creating a function to get the extention of a file. 		We then create a variable that uses the 'strstr' function. 		strstr = Find first occurrence of a string, says php.net/strstr 		We then call the $file variable up and then add a object to look for. 		In this case, it is the "." (period). 		We then return the variable 	*/ if($submit){		 $file = $_FILES['image_file']; 		 		/* 		  So the submit button was pressed. 			We then create a variable and call the file using $_FILES['INPUT_NAME_HERE']; 		*/ 		 		if($file == NULL){ 		  echo "No image selected."; 			/* If no file was selected, echo the error. */ 		}else{ 					  			$file_name = $_FILES['image_file']['name']; 			$up_path = $path.$file_name; 			$ext = get_ext($file); 			 			list($width, $height, $ftype, $attr) = getimagesize($_FILES['image_file']['tmp_name']); 			$fileExt = explode(",",$allowedExt); 			 			/* List = Assign variables as if they were an array - php.net/list  			  so we are assigning 4 different variables, width, height, file type and attributes 				We will not be using $ftype or $attr, they are merely there to show you. 				 				We are also creating a new variable with the explode function on our allowed file extentions. 			*/ 			 			if ($width > $maxWidth){ 			  echo "The width of the image can only be: ".$maxWidth."px"; 			}elseif ($height > $maxHeight){ 			  echo "The height of the image can only be: ".$maxHeight."px"; 				/* We did a check to see if the width and height are the correct sizes. */ 			}elseif (!in_array($ext,$fileExt)){ 			  echo "File extention not recognized.<br /> Allowed extentions: ".$allowedExt; 				/* We check if the extention of the file is in the array we made. */ 			}else{ 			  if(move_uploaded_file($file_name,$up_path)){ 				  echo "Image: '".$file_name."' has successfully beed uploaded to: '".$path."'"; 					/* If the file was moved to the folder, we echo the message and move the file */ 				}else{ 					echo "Error with uploading the image."; 					/* 					  If the file was not moved, echo the error 					  This could be because the path specified was incorrect or the folder was not CHMOD'ed correctly 					*/ 				} 			  if(!$title){  //this means If the title is really empty.					 echo "Error: Game Name is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$body){  //this means If the title is really empty.					 echo "Error:Main review body is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$platform){  //this means If the title is really empty.					 echo "Error:Game Platform is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$genre){  //this means If the title is really empty.					 echo "Error:Game Genre is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$gameplay){  //this means If the title is really empty.					 echo "Error:Gameplay rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$graphics){  //this means If the title is really empty.					 echo "Error:Graphics rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$sound){  //this means If the title is really empty.					 echo "Error:Sound rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }			  elseif(!$multiplayer){  //this means If the title is really empty.					 echo "Error:Multiplayer rating is a required field. Please fill it.";					 exit(); //exit the script and don't do anything else.			  }						  else {$author = mysql_query("SELECT username FROM `users` Where id=' " . $_SESSION['id'] . " ' " );$auth = @mysql_fetch_assoc($author);$rauthor = $auth;$date = time();echo make_datestr(time());$result = mysql_query("INSERT INTO reviews (title, body, author, date_added, platform, genre, gameplay, graphics, sound, multiplayer, picture)					   VALUES ('$title','$body','$rauthor','$date','$platform','$genre','$gameplay','$graphics','$sound','$multiplayer','$imagename')");echo "<b>Thank you! Review added Successfully!<br>Your review will be on display after being approved by our editors.<br>You'll be redirected to Home Page after (4) Seconds";		  echo "<meta http-equiv=Refresh content=4;url=index.php>";} }else{echo "No form was submitted";}?>

and this is the erro i get Parse error: syntax error, unexpected T_ELSE in D:\xampp\htdocs\addr.php on line 121also plz read my 5th last post where i posted the html code also and read my question there also plz and please if u can answer them. :)

Link to comment
Share on other sites

Hmm... you have nesting errors :). Umm... ok - first have a look at the $file variable handler. There, we test whether the form is submitted. Ok, so 1 conditional is in progress, with 0 levels of nesting. Then we have an if to test whether the file is set. 1 level of nesting. Then, we have another if to test whether the user's image conforms to regulations. 2 level of nesting. Inside that block, we have another if to see whether the file uploaded ok. 3 levels of nesting. That block is then closed. 2 level of nesting. Now, only if the image conforms, we now go on to see whether all the required variables are set. 3 levels of nesting. If they all are, we display a message. Still 3 levels of nesting. Then, we close two blocks, bringing it to 1 level of nesting. Now, here is your problem. You have an else statement to report that there was no data to submit, but you have not put enough closing braces ( } ) to get there, and you are actually writing an else statement for the image conformity tests, which already has an else block. So, you can't have another one. What you should have is two more closing braces, so

editors.<br>You'll be redirected to Home Page after (4) Seconds";		  echo "<meta http-equiv=Refresh content=4;url=index.php>";}}}}else{echo "No form was submitted";}?>

There, I think that was what the problem was...Hmm... I can't look at your other problem now, but I will try to another time. Happy coding :)

Link to comment
Share on other sites

ok i tried this code

if (isset($submit)){

but it still shows no form was submitted so what code shud i use?and i also tried this code

if (isset($_POST['submit'])){

but still shows no form was submitted so what shud i use exactly?

Link to comment
Share on other sites

I can't tell you without seeing the form. You just need to check for the existence of any field that is in the form, so you can check for any field that has a name. You can put a name on the submit button if you want to use that.

Link to comment
Share on other sites

here is the form and the submit already has a name that is submithtml form

<html><!-- Created on: 7/19/2007 --><head>  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">  <title>Gamerz Galore Add A Review</title>  <meta name="description" content="">  <meta name="keywords" content="">  <meta name="author" content="Unregistered User">  <meta name="generator" content="AceHTML Freeware"><link rel="stylesheet" type="text/css" href="add.css"></head><body><center><div id="body"><form action="addr.php" method="post" enctype="multipart/form-data">Game Name: <input type="text" name="title" size="40" maxlength="200"><br>Content:  <textarea name="body" cols="50" rows="15"> </textarea> <br>Platform:  <select name="platform">	<option value="Xbox360"> Xbox360</option>	<option value="PS3"> PS3</option>	<option value="PC"> PC</option></select>	 			<br>	<tr><td>Genre:<select name="genre">	<option value="Racing"> Racing</option>	<option value="Action"> Action</option>	<option value="Adventure"> Adventure</option>	<option value="Sports"> Sports</option></select>					  <br>			<b>Rating</b>	<br>  Gameplay:  <select name="gameplay">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>			  <br>Graphics:<select name="graphics">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>		  <br>Sound:<select name="sound">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>			<br>Multiplayer:<select name="multiplayer">	<option value="1"> 1</option>	<option value="2"> 2</option>	<option value="3"> 3</option>	<option value="4"> 4</option>	<option value="5"> 5</option>	<option value="6"> 6</option>	<option value="7"> 7</option>	<option value="8"> 8</option>	<option value="9"> 9</option>	<option value="10"> 10</option></select>		  <br>		Image:<input type="file" name="image_file"><br><br><br><br><input type="submit" name="Submit" value="Submit">	   </form></div></center></body></html>

i am guessing the prob is with the php script?

Link to comment
Share on other sites

ah thnkxnow it is giving me this errorFile extention not recognized.Allowed extentions: .gif,.bmp,.png,.jpgalthought i am uploading an image that is in .bmp format i also tried .gif and .jpg but all give the same error?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...