Login   Register  
PHP Classes
elePHPant
Icontem

Two warnings and equal parameters fault

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Extended MySQLi  >  All threads  >  Two warnings and equal parameters fault  >  (Un) Subscribe thread alerts  
Subject:Two warnings and equal parameters fault
Summary:Getting two warnings and "equal parameters" fault
Messages:3
Author:Vincent
Date:2010-03-01 14:04:46
Update:2010-04-06 15:58:11
 

  1. Two warnings and equal parameters fault   Reply  
Picture of Vincent
Vincent
2010-03-01 14:04:46
Hello there,

I'm currently testing your class and it looks good however.

Immediately after starting using it two errors showed up:

<b>Warning</b>: The magic method __call() must have public visibility and cannot be static in <b>C:\xampp\htdocs\energyroms\admin\classes\mysql.class.php</b> on line <b>81</b><br />
<br />
<b>Warning</b>: The magic method __get() must have public visibility and cannot be static in <b>C:\xampp\htdocs\energyroms\admin\classes\mysql.class.php</b> on line <b>119</b><br />

Also whenever I try parameters in a query, it fails.

For example I have a query that goes like this:
$Username = $_POST['UserName'];
$EncryptedPassword = doubleSalt($Password, $Username);
$aRes = $dbLink->query('SELECT UserID,UserGroup FROM users WHERE UserName = ? AND UserPassword = ?',$Username,$EncryptedPassword);

I always get the error:
[query_number] => 1
[query] => SELECT UserID,UserGroup FROM users WHERE UserName = ? AND UserPassword = ?
[errno] => 0
[type] => fatal
[error] => [ERROR] Failed to bind. Do you have equal parameters for all the '?'?

Now, I made sure that $Username and $EncryptedPassword both actually contain something so...

Is this class broken on my version of php? (PHP Version 5.3.1, using Xampp)

Or did I screw up? :)

  2. Re: Two warnings and equal parameters fault   Reply  
Picture of Camilo Sperberg
Camilo Sperberg
2010-03-01 21:07:46 - In reply to message 1 from Vincent
Hi Vincent ;) Thanks for your feedback.

I have just tested (like a week ago) this class on the same platform as you, but I really can't tell you if it is because of Windows or the PHP version, however, I think it could be Windows.

There is however, a small bug in this class: all "__" methods (__call, __get, etc) MUST be public. That's something I didn't know when I wrote this class.


I've tested this class on the Linux PHP's versions 5.1.6, 5.2.0, 5.2.6 and 5.2.8, but on Linux versions > 5.3 I haven't been able to test it.

However, when I tested this class, there was a little solution that helped, instead of:

<?php
$dbLink->query('SELECT * FROM t1 WHERE a = ? LIMIT ?',1,1);
?>

try with this:

<?php
$dbLink->query('SELECT * FROM t1 WHERE a = '.1.' LIMIT 1');
?>

That is something that worked for me. I will try to install and test PHP5.3 on Linux to see if it is a Windows or a programming error, but I won't have much time to test :(

Greetings !!

  3. Re: Two warnings and equal parameters fault   Reply  
Picture of Camilo Sperberg
Camilo Sperberg
2010-04-06 15:58:11 - In reply to message 2 from Camilo Sperberg
Some news: just installed PHP 5.3.2 on a linux box and no errors showed up with the queries, so this is a Windows specific bug. I remember I tried messing up with the configuration, with the class itself and with Apache / MySQL configuration, but nothing helped except not parametrizing the queries.

If you have found the solution, please post it so it can be included in the next version, I don't develop on Windows and the only time I worked on Windows I couldn't get used to it and changed back to Linux after 5 days.

Greetings !!