0

Hi,
My mysql_error is No Database Selected.
errno 1046
I am connected to the database and it has worked fine before so I was wondering what I am doing wrong.
The code is from a tutorial I am using.

<?php require_once('Connections/connAdmin.php'); ?>

<?php
//file properties
$file = $_FILES['content']['tmp_name'];

if
(!isset($file))
echo "please select an image.";
else {
$content = addslashes (file_get_contents ($_FILES['content']['tmp_name']));
$content_name = addslashes ($_FILES['content']['name']);
$content_size = getimagesize ($_FILES['content'] ['tmp_name']);

if ($content_size ==FALSE)
echo "Thats not an image";
else {
	if (!$insert = mysql_query("INSERT INTO upload VALUES('';'$content_name';'$content')"))
echo (mysql_errno());
else{
	$lastid = mysql_insert_id();
	echo "Image uploaded<p/>Your Image<p/><img src=get.php?$lastid>";
}
}
}
?>

everything seems to work up until the INSERT script.
Thanks!

3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by phpDave
0

dont write ; between the values, do 'your value','another value', ...

and change

if ($content_size ==FALSE)

to this

if (!$content_size)
0

Thanks, I can't believe I used the ; instead of ,
Anyway, fixed that but still not working.

0

Could please provide Connections/connAdmin.php ?
Is connAdmin.php code is working right ?

0

Yes, connection is working. I get it to work for a while then it stops working, very strange.

0

No, I don't think so. I'm looking through everything now. It looks the same as when it was working.

0

I changed the INSERT to:

if (!$insert = mysql_query("INSERT INTO dcktest.upload VALUES('','$content_name','$content')"))
echo (mysql_error());

And the same for get.php and it seems to work now, I'm still open to comments for of it stops working again. Still not sure why.
PS. dcktest is name of database.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.