I followed a set of posts on this site on how to do this but being the noob that I am got stuck :)
My code runs as follows:
<?php
$dbhost = '******';
$dbuser = '******';
$dbpass = '******';
$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = '******';
mysql_select_db ($dbname);
$fol = "./Imgs/images/";
$dir = opendir ($fol);
while (false !== ($file = readdir($dir))) {
if (strpos($file, '.gif',1)||strp os($file, '.jpg',1) ) {
// (This was just for testing) echo "<a href=\"".$fol." ".$file."\">".$ file."</a><br />";
$query = 'INSERT INTO `******`.`***** *` (`id`, `pasta`, `nome`) VALUES (NULL, $fol, $file);';
mysql_query($qu ery) or die('Error, insert query failed');
}
}
?>
It gives me 'Error, insert query failed' and I assume it's because of the variables
Can someone help?
PS: The $fol variable exists because it will be eventualy replaced by form variable.
Thanks in advance
My code runs as follows:
<?php
$dbhost = '******';
$dbuser = '******';
$dbpass = '******';
$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = '******';
mysql_select_db ($dbname);
$fol = "./Imgs/images/";
$dir = opendir ($fol);
while (false !== ($file = readdir($dir))) {
if (strpos($file, '.gif',1)||strp os($file, '.jpg',1) ) {
// (This was just for testing) echo "<a href=\"".$fol." ".$file."\">".$ file."</a><br />";
$query = 'INSERT INTO `******`.`***** *` (`id`, `pasta`, `nome`) VALUES (NULL, $fol, $file);';
mysql_query($qu ery) or die('Error, insert query failed');
}
}
?>
It gives me 'Error, insert query failed' and I assume it's because of the variables
Can someone help?
PS: The $fol variable exists because it will be eventualy replaced by form variable.
Thanks in advance
Comment