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
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()); 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

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.