[PHP-DB] strange results in mysql with readdir.php

2004-06-06 Thread Alessandro Folghera
Anybody has an idea about what happened to me ? 

The following script should just charge in a mysql db the images located in
a directory. Unfortunately everytime I call readdir.php (never mind if
there are or not new images) mysql is charging 2 or 6 copies of the same
last image uploaded into the directory. Anybody may explain to me where I'm
failing?
Thanks for all the phpers!
Alessandro

?
$dbcnx = mysql_connect(localhost, root, password); 
mysql_select_db(news);

if (!$dbcnx) 
{ 
echo( pconnection to database server failed!/p);
exit();
} 

if (! @mysql_select_db(news) )
{ 
echo( pImage Database Not Available!/p  ); 
exit(); 
}

$path = ./;
$dir_handle = @opendir($path) or die(Unable to open directory $path);

while ($file = readdir($dir_handle)) {
$filetyp = substr($file, -3);
if ($filetyp == 'gif' OR $filetyp == 'jpg') {
$handle = fopen($path . / . $file,'r');
$file_content = fread($handle,filesize($path . / . $file));
fclose($handle);

$encoded = chunk_split(base64_encode($file_content)); 
$sql = INSERT INTO images SET sixfourdata='$encoded'; 

@mysql_query($sql);
}
}
closedir($dir_handle);
echo(complete);
?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] strange results in mysql with readdir.php

2004-06-06 Thread Daniel Clark
I'd think there where multiple files with jpg and gif extensions.

Like:

image1.jpg
image1.jpg.jpg


Anybody has an idea about what happened to me ? 

The following script should just charge in a mysql db the images located in
a directory. Unfortunately everytime I call readdir.php (never mind if
there are or not new images) mysql is charging 2 or 6 copies of the same
last image uploaded into the directory. Anybody may explain to me where I'm
failing?
  Thanks for all the phpers!
  Alessandro

?
$dbcnx = mysql_connect(localhost, root, password); 
mysql_select_db(news);

if (!$dbcnx) 
{ 
echo( pconnection to database server failed!/p);
exit();
} 

if (! @mysql_select_db(news) )
{ 
echo( pImage Database Not Available!/p  ); 
exit(); 
}

$path = ./;
$dir_handle = @opendir($path) or die(Unable to open directory $path);

while ($file = readdir($dir_handle)) {
$filetyp = substr($file, -3);
if ($filetyp == 'gif' OR $filetyp == 'jpg') {
$handle = fopen($path . / . $file,'r');
$file_content = fread($handle,filesize($path . / . $file));
fclose($handle);

$encoded = chunk_split(base64_encode($file_content)); 
$sql = INSERT INTO images SET sixfourdata='$encoded'; 

@mysql_query($sql);
}
}
closedir($dir_handle);
echo(complete);
?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: strange results in mysql with readdir.php

2004-06-06 Thread Rui Cunha
Alessandro, 

i think the sql insert statement should be: 

insert into images(sixfourdata) values ('$encoded'); 

Rui Cunha 

Alessandro Folghera writes: 

Anybody has an idea about what happened to me ?  

The following script should just charge in a mysql db the images located in
a directory. Unfortunately everytime I call readdir.php (never mind if
there are or not new images) mysql is charging 2 or 6 copies of the same
last image uploaded into the directory. Anybody may explain to me where I'm
failing?
	Thanks for all the phpers!
		Alessandro 

?
$dbcnx = mysql_connect(localhost, root, password); 
mysql_select_db(news); 

if (!$dbcnx) 
{ 
echo( pconnection to database server failed!/p);
exit();
}  

if (! @mysql_select_db(news) )
{ 
echo( pImage Database Not Available!/p  ); 
exit(); 
} 

$path = ./;
$dir_handle = @opendir($path) or die(Unable to open directory $path); 

while ($file = readdir($dir_handle)) {
$filetyp = substr($file, -3);
if ($filetyp == 'gif' OR $filetyp == 'jpg') {
$handle = fopen($path . / . $file,'r');
$file_content = fread($handle,filesize($path . / . $file));
fclose($handle); 

$encoded = chunk_split(base64_encode($file_content)); 
$sql = INSERT INTO images SET sixfourdata='$encoded';  

@mysql_query($sql);
}
}
closedir($dir_handle);
echo(complete);
? 


*
* Rui Pedro Cunha   *
* Dpto. de Ciências e Tecnologias   *
* Universidade Autónoma de Lisboa   *
* Rua de Santa Marta, 56,   *
* 1169-023 Lisboa   *
* Telefone  (+351) 21 317 76 35/49  *
* Fax   (+351) 21 353 37 02 *
* Url : http://www.ual.pt/dct/  *
* E-mail: [EMAIL PROTECTED]  *
* 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Error loading module: Unable to load dynamic library

2004-06-06 Thread Christopher Jones
Philippe wrote:
Well, the exact message is: Unable to load dynamic library 
php_oci8.dll: The specified procedure could not be found
If I remove the library the message becomes The specified module could 
not be found. It seems to be able to find the library (all the paths 
are correct) but it seems that this php_oci8.dll file is the wrong 
version or that it is looking for an additional DLL that it can't find 
OR that it can find the additional DLL but it is the wrong version. If I 
only knew what DLL was needed!
Philippe

The common problem would be that php_oci8.dll cannot find Oracle's libraries.
Have you elimated this as the problem?
There are a coupel of things to try:
(i) Check phpinfo() output.  Make sure PATH in the Apache env section contains
the Oracle bin directory.  If this is not clear in my FAQ, please let me know
so I can update the FAQ.  Currently
   http://otn.oracle.com/tech/opensource/php/php_troubleshooting_faq.html#envvars
says:
If Apache starts but gives errors about Oracle libraries and/or
OCI8 function calls fail, try looking at PHP's environment. Create
the following script phpinfo.php where your web server can read
it and load it in a browser:
?php
  phpinfo();
?
Triple-check the environment and path configuration. On UNIX check
that LD_LIBRARY_PATH (or equivalent) contains $ORACLE_HOME/lib. On
Windows the PATH variable may need to contain %ORACLE_HOME%\bin.
(ii) Install http://www.dependencywalker.com/ and run it on php_oci8.dll
I'll look into adding a comment about this utility in the next FAQ update.
Chris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php