RE: [PHP-DB] $db=new mysqli fails while $db=mysqli_connect succeeds in PHP/MySQL

2007-08-27 Thread Instruct ICC

From a php-general thread earlier:

  ?php
  $db=new mysqli('localhost','whil','secret','test');
  ?

generates:

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

while

  ?php
  $conn = mysqli_connect(localhost,whil,secret,test);
  echo 'conn good: '.$conn.' :very good indeedbr';
  ?

generates success:

  conn good: Object id #1 :very good indeed

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?


Whil


I don't see a constructor for mysqli at http://php.net/mysqli
Your book is probably defining a class that you didn't include/require.  For 
example, search for the following at the php page above:

require_once('safe_mysqli.php');
try {
   $mysql = new safe_mysqli

You will need to have the class your book is defining before you can 
instantiate such an object.


_
Find a local pizza place, movie theater, and more….then map the best route! 
http://maps.live.com/default.aspx?v=2ss=yp.bars~yp.pizza~yp.movie%20theatercp=42.358996~-71.056691style=rlvl=13tilt=-90dir=0alt=-1000scene=950607encType=1FORM=MGAC01


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



RE: [PHP-DB] $db=new mysqli fails while $db=mysqli_connect succeeds in PHP/MySQL

2007-08-27 Thread Instruct ICC

I don't see a constructor for mysqli at http://php.net/mysqli;

My bad.  It's right there at the top.  Must be a case of the Mooondayz.

_
Now you can see trouble…before he arrives 
http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_protection_0507


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



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

2007-08-27 Thread Linux NG/Lists
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 soo puzzled. :)

Whil

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



[PHP-DB] Integer in DB becomes string in PHP?

2007-08-27 Thread hjfg sdfdsf
hello,

I have a table test_table with one column:
number int(11)
(also see phpmyadmin database dump at the end of this mail).
it has two values, 123 and 150.

i select and output one of those numbers using the following code:
--- php code start ---
?
error_reporting(E_ALL);

$con=mysql_connect('127.0.0.1', 'root', '');
mysql_select_db('testdb', $con);
$result=mysql_query('select * from test_table where number=123');
$row=mysql_fetch_array($result);


print_r($row);

var_dump($row['number']);
?
--- php code end ---

that outputs:
--- output start ---

Array
(
[0] = 123
[number] = 123
 )
string(3) 123
--- output end ---



1) Is this normal?
2) Can this behaviour be changed / fixed?

Thanks!





   
-
 Wissenswertes für Bastler und Hobby Handwerker.BE A BETTER HEIMWERKER!

RE: [PHP-DB] Integer in DB becomes string in PHP?

2007-08-27 Thread Daevid Vincent
You could use intval($row['number']); to force it, but be careful that
you may hit upper bounds around 2 Billion as integers are always signed
in PHP (unfortunately), and mysql lets you store unsigned. It'll also
depend on your OS.

If you're checking the value only, you can use
is_numeric($row['number']) I think.

And also keep in mind that PHP will cast on the fly as needed...

If ($row['number'] == '123')

And

If ($row['number'] == 123)

Will both return true.

Also, could you change your name from hjfg sdfdsf to something more
sane -- unless that really is your name, then I feel sorry for you and
would advise you to go on Wheel of Fortune, and buy a vowel...

ÐÆ5ÏÐ 

Some people, when confronted with a problem, think 'I know, I'll use
XML.'
Now they have two problems. 

 -Original Message-
 From: hjfg sdfdsf [mailto:[EMAIL PROTECTED] 
 Sent: Monday, August 27, 2007 1:59 PM
 To: php-db@lists.php.net
 Subject: [PHP-DB] Integer in DB becomes string in PHP?
 
 hello,
 
 I have a table test_table with one column:
 number int(11)
 (also see phpmyadmin database dump at the end of this mail).
 it has two values, 123 and 150.
 
 i select and output one of those numbers using the following code:
 --- php code start ---
 ?
 error_reporting(E_ALL);
 
 $con=mysql_connect('127.0.0.1', 'root', '');
 mysql_select_db('testdb', $con);
 $result=mysql_query('select * from test_table where number=123');
 $row=mysql_fetch_array($result);
 
 
 print_r($row);
 
 var_dump($row['number']);
 ?
 --- php code end ---
 
 that outputs:
 --- output start ---
 
 Array
 (
 [0] = 123
 [number] = 123
  )
 string(3) 123
 --- output end ---
 
 
 
 1) Is this normal?
 2) Can this behaviour be changed / fixed?
 
 Thanks!
 
 
 
 
 

 -
  Wissenswertes für Bastler und Hobby Handwerker.BE A BETTER 
 HEIMWERKER!
 

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