Re: $db=new mysqli fails while $db=mysqli_connect succeeds in PHP/MySQL 5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Goltsios Theodore wrote:
Well if you are in the unix case then you should check if your php supports mysqli :-) . In either case unix or not you could use phpinfo:

<?php
   phpinfo();
?>


Oh, sorry, I thought I posted this before. Looks like I didn't. I'm pretty sure it supports mysqli:

'./configure' '--prefix=/usr/local/php5' '--with-config-file-path=/usr/local/etc/php5/cgi' '--with-xml' '--enable-bcmath' '--enable-calendar' '--with-curl' '--with-dom' '--with-dom-xslt' '--with-dom-exslt' '--enable-exif' '--with-swf=/usr/local/flash' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-gettext' '--with-imap=/usr/local/imap-2004g' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-mcrypt' '--with-mhash' '--enable-magic-quotes' '--with-mysqli' '--with-mysql=/usr' '--with-openssl' '--enable-discard-path' '--with-pear' '--with-pspell' '--enable-sockets' '--enable-track-vars' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--with-zip' '--with-zlib'

The 'mysqli_connect(...' call works, just not 'new mysqli(...'

If mysqli wasn't supported, then both would fail, right?

Whil




This will show a lot useful information about what your web server and your php can or cannot do.


Linux NG/Lists wrote:
The book I'm working with (PHP & MySQL Web Dev, Welling/Thompson) specifically defines the 'new mysqli' syntax. So I'm guessing I don't have something configured right?

If one works the other should too. Your code here looks fine according to the manual (http://www.php.net/manual/en/function.mysqli-connect.php) - can you send us exactly what you have?

OK, here's what I've got, cut and pasted directly out of the script:

********************************************
<body>

<?php
echo('Today is... ' . date('l, F dS Y. ').'<br>' );
?>

<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
?>

<?php
$db=new mysqli("localhost","whil","secret","test");
echo '$db is:'.$db.':';
$conn = mysqli_connect("localhost","whil","secret","test");
echo '$conn is:'.$conn.':';
?>

</body>
********************************************

1. If I comment out the $db and echo $db lines, the next two lines, $conn and echo $conn generate the following:

  Today is... Monday, August 27th 2007.
  $conn is:Object id #1:

2. If I remove the $db and echo $db comments, I get the following:

  Today is... Monday, August 27th 2007.

  Fatal error: Call to undefined function new mysqli() in
  index_listtest.php on line 17

I'm soooooooooo puzzled. :)

Whil



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux