annaright Posted November 25, 2011 Share Posted November 25, 2011 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"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/251767-how-to-insert-get-variable-into-mysql/ Share on other sites More sharing options...
Psycho Posted November 25, 2011 Share Posted November 25, 2011 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()); Quote Link to comment https://forums.phpfreaks.com/topic/251767-how-to-insert-get-variable-into-mysql/#findComment-1291067 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.