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
https://forums.phpfreaks.com/topic/195205-php-mysql-query-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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