Jump to content

[SOLVED] Not entering into database.


daniel5455

Recommended Posts

I have a page where i can add products and for some reason when i fill out the information and press add product i dont see the data in the database. I get "The product added successfully" on the screen. I can delete the products but not create them so that should tell me the user info is correct. I did verify the user account and it has full privs.

 

<?php require_once($_SERVER[DOCUMENT_ROOT] . "/includes/config.php"); ?>
<?php
			session_start();	
			if(!isset($_SESSION["userid"]) || !isset($_SESSION["usertype"]) )
			{						
				echo "<script>document.location='login.php';</script>";
				header( 'Location: login.php' ) ;					
			}
			else
			{
				if($_SESSION["usertype"] != "admin")
				{
					echo "<script>document.location='login.php';</script>";
					header( 'Location: login.php' ) ;
				}
			}





				if ((($_FILES["image"]["type"] == "image/gif")|| ($_FILES["image"]["type"] == "image/jpeg")|| ($_FILES["image"]["type"] == "image/pjpeg")|| ($_FILES["image"]["type"] == "image/jpg")|| ($_FILES["image"]["type"] == "image/bmp")|| ($_FILES["image"]["type"] == "image/png"))&& ($_FILES["image"]["size"] < 5000000))
				{
					$target_path = "./productimages/";
					$target_path = $target_path . basename( $_FILES['image']['name']); 

					$title=$_POST['title'];
					$item=$_POST['item'];
					$price=$_POST['price'];
					$processor=$_POST['processor'];
					$image=$_FILES['image']['name'];
					$memory=$_POST['memory'];
					$hdd=$_POST['hdd'];
					$cdrom=$_POST['cdrom'];
					$display=$_POST['display'];
					$other=$_POST['other'];
					$os=$_POST['os'];
					$warranty=$_POST['warranty'];
					$type=$_POST['type'];
					$make=$_POST['make'];					

					if(!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
						echo "<span style='color:green'> Image could not be copied <br></span>";
					} 	
					// mysql_query("INSERT INTO product (title,item,price,processor,image,memory,hdd,cdrom,display,other,os,warranty,type,make) VALUES ('$title','$item','$price','$processor','$image','$memory','$hdd','$cdrom','$display','$other','$os','$warranty','$type','$make')");
					mysql_query("INSERT INTO `product` (`id` , `title` , `item` , `price` , `processor` , `image` , `memory` , `hdd` , `cdrom`, `display` , `other` , `os` , `warranty` , `type` , `make`) VALUES (NULL, '$title','$item','$price','$processor','$image','$memory','$hdd','$cdrom','$display','$other','$os','$warranty','$type','$make')");
					echo "<span style='color:green'> The product added successfully </span>";
				}
				else
					echo "<span style='color:green'> File is not supported or size is too large </span>";




	?>

Link to comment
https://forums.phpfreaks.com/topic/122044-solved-not-entering-into-database/
Share on other sites

Add a die error to the end of your query

 

mysql_query("INSERT INTO `product` (`id` , `title` , `item` , `price` , `processor` , `image` , `memory` , `hdd` , `cdrom`, `display` , `other` , `os` , `warranty` , `type` , `make`) VALUES (NULL, '$title','$item','$price','$processor','$image','$memory','$hdd','$cdrom','$display','$other','$os','$warranty','$type','$make')")or die(mysql_error());

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.