Jump to content

php + mysql query problem


karq

Recommended Posts

function if_exist($imgDir,$thumbDir,$datainf){
//Vajalik info
include($datainf);
$pic = opendir($imgDir);
$thumb = opendir($thumbDir);
$suva = rand(0,9999);
$peakiri = " pilt";

//Code part
while (($pics = readdir($pic)) && ($thumbs = readdir($thumb)) ){
if ($pics != ".." && $pics != "." && $thumbs !=".." && $thumbs !="."){
	//lets check that the files are in dirs and arent on the database
	$kontroll = $thumbDir . "/" . $pics;
		//is in dir
	if (file_exists($kontroll)){ $kont_dir = true; }
		else {$kont_dir = false;}
		//isnt in database
		$thump = "./".$thumbDir . "/" . $pics;
		$kont_data = mysql_query("SELECT * FROM pildid WHERE thumbpath = '$thump'",$con) or die (mysql_error());
		print $kont_data;
		if ($kont_data){$kont_base = true;}
				else { $kont_base = false;}

	//lets insert when everything is ok
	$img = "./pildid/".$pics;
	$thump = "./dPildid/".$pics;
	if ($kont_dir == true && $kont_base == true){
		$add_inf = "INSERT INTO pildid (path,thumbpath)
			VALUES ('$img','$thump')";
		if (!mysql_query($add_inf,$con)) {
				die("error: " . mysql_error());
			}
			else {
				echo $pics . " on ylesse laetud!";
			}
			mysql_close($con);
	}





	}
}

}

 

And I get this error:

Resource id #8Neljapaev064.JPG on ylesse laetud!Resource id #9Misc004.JPG on ylesse laetud!
Warning: mysql_query(): 4 is not a valid MySQL-Link resource in /home/kaarel/progemine/php/fotoleht/admin/function.php on line 77

 

It insers only 2 picture infos.

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.