ID: 39174 User updated by: tjerk dot meesters at gmail dot com Reported By: tjerk dot meesters at gmail dot com -Status: Bogus +Status: Closed Bug Type: MySQL related Operating System: Linux 2.6 PHP Version: 5.1.6 New Comment:
Argh, I can't believe how stupid that was ... mea culpa Previous Comments: ------------------------------------------------------------------------ [2006-10-17 13:11:54] [EMAIL PROTECTED] var_dump() is function you are looking for. var_export() exports variables to a parsaable strings, but resources cannot be represented as strings due to their nature. ------------------------------------------------------------------------ [2006-10-17 12:05:55] tjerk dot meesters at gmail dot com Description: ------------ A simple mysql_connect() returned NULL for this particular configuration of PHP: --with-mysql=/usr/lib/mysql --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr When the script is ran with wrong login credentials, mysql_connect() returns false as documented. However, when everything checks out no errors are thrown and NULL is returned instead of a resource. This is not documented behaviour as far as I know ;-) Reproduce code: --------------- <?php error_reporting(E_STRICT); $r = mysql_connect('localhost','user','pw'); var_export($r); ?> Expected result: ---------------- "Resource #1" (or something similar) Actual result: -------------- "NULL" A strace on the process returns the following: ... socket(PF_FILE, SOCK_STREAM, 0) = 3 fcntl64(3, F_SETFL, O_RDONLY) = 0 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 connect(3, {sa_family=AF_FILE, path="/var/run/mysqld/mysqld.sock"}, 110) = 0 fcntl64(3, F_SETFL, O_RDWR) = 0 setsockopt(3, SOL_IP, IP_TOS, [8], 4) = -1 EOPNOTSUPP (Operation not supported) setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0 poll([{fd=3, events=POLLIN, revents=POLLIN}], 1, 60000) = 1 read(3, "9\0\0\0\n5.0.24a-log\0\331\1\0\0TOlT=vZ?\0,\242"..., 16384) = 61 brk(0x8747000) = 0x8747000 stat64("/usr/share/mysql/charsets/Index.xml", {st_mode=S_IFREG|0644, st_size=18221, ...}) = 0 open("/usr/share/mysql/charsets/Index.xml", O_RDONLY|O_LARGEFILE) = 4 read(4, "<?xml version=\'1.0\' encoding=\"ut"..., 18221) = 18221 close(4) = 0 write(3, ">[EMAIL PROTECTED]"..., 66) = 66 read(3, "\7\0\0\2\0\0\0\2\0\0\0", 16384) = 11 fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f00000 write(1, "NULL", 4NULL) = 4 close(0) = 0 An ldd on the php cli: ... libmysqlclient.so.15 => /usr/lib/mysql/libmysqlclient.so.15 (0xb78f6000) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39174&edit=1