Jump to content

how to insert $GET variable into mysql


annaright

Recommended Posts

Hi anyone here know how to insert $GET variable into mysql, i don't know how to put this variable between curly bracket, when i put on top insert query, i got error 'Could not insert admin'...please help  :'(

 

<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("healthsystem") or die(msql_error());

[color=red]//GET varibable

$id = $_GET['id'];[/color]




// file properties
$file = $_FILES['image']['tmp_name'];


if (!isset($file))


echo "Please select an image";

else
{

$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);

     

if ($image_size==FALSE)
	echo "That's not an image.";
else
{

	$insert = "INSERT INTO image_tbl(m_id,name,image) VALUES ('$id','$image_name','$image')";
	$insert2=mysql_query($insert) or die("Could not insert admin"); 
    	print "Personal Wellness Successfully Submitted";


}
}


?>

Link to comment
https://forums.phpfreaks.com/topic/251767-how-to-insert-get-variable-into-mysql/
Share on other sites

Having an error such as "Could not insert admin" for users when in a production environment is fine. But, when you are in development you need to provide error handling that will help you find and fix errors.

 

This will display the query and the error returned from MySQL:

$insert2=mysql_query($insert) or die("Query: {$insert}<br>Error: " . 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.