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!

Recommended Answers

All 7 Replies

Member Avatar for P0lT10n

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

and change

if ($content_size ==FALSE)

to this

if (!$content_size)

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

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

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

Member Avatar for P0lT10n

did you wrongly deleted or changed the db or values of it ???

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.