Author Topic: Backend "Add/Update User Information" problem with mysqli  (Read 6391 times)

6J8Y4f

  • Beginner
  • *
  • Posts: 3
Backend "Add/Update User Information" problem with mysqli
« on: January 20, 2011, 13:32:41 pm »
Hi.
I use Joomla 1.5.22 with Virtuemart 1.1.6 and Joomfish 2.1.5.
This Joomfish version needs a mysqli connection to the database, which I set up in the backend in "site -> global configuration -> server -> database settings -> database type".
Otherwise you will get an error during checkout (http://forum.virtuemart.net/index.php?topic=78987.0 and http://www.joomfish.net/forum/viewtopic.php?f=24&t=7324).
With mysql I have now a problem in the virtuemart backend in "admin -> users -> select username -> shopper information".
Updating the settings here results in a database error:
Code: [Select]
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2) in /homepages/14/d35228958/htdocs/shop/root/administrator/components/com_virtuemart/classes/ps_user.php on line 260
Here are other php files beside "./administrator/components/com_virtuemart/classes/ps_user.php", that might have the same problem:
./administrator/components/com_virtuemart/classes/ps_cart.php
./administrator/components/com_virtuemart/CHANGELOG.php
./libraries/phpinputfilter/inputfilter.php
./libraries/simplepie/simplepie.php
./libraries/joomla/database/database/mysql.php
./libraries/geshi/geshi/php-brief.php
./libraries/geshi/geshi/php.php

Thanks

6J8Y4f

  • Beginner
  • *
  • Posts: 3
Re: Backend "Add/Update User Information" problem with mysqli
« Reply #1 on: January 21, 2011, 23:45:37 pm »
I made the following change to "administrator/components/com_virtuemart/classes/ps_user.php" in line 260 for the user update in the Virtuemart backend to work:
Old:
Code: [Select]
$fields[] = "`".$userField->name."`='".mysql_real_escape_string($d[$userField->name])."'";New:
Code: [Select]
$fields[] = "`".$userField->name."`='".$db->getEscaped($d[$userField->name])."'";
The function getEscaped() is in "libraries/joomla/database/database/mysqli.php":
Code: [Select]
function getEscaped( $text, $extra = false )
{
        $result = mysqli_real_escape_string( $this->_resource, $text );
        if ($extra) {
                $result = addcslashes( $result, '%_' );
        }
        return $result;
}

It has the option to use addcslashes(). Is this necessary in ps_user.php? Is my solution valid?

superthomas

  • Beginner
  • *
  • Posts: 1
Re: Backend "Add/Update User Information" problem with mysqli
« Reply #2 on: January 28, 2011, 13:57:30 pm »
Hello,

i had exactly the same problem with Vm + Joomfish and also made the database change to "mysqli".

So your fix

Quote
New:
Code:
$fields[] = "`".$userField->name."`='".$db->getEscaped($d[$userField->name])."'";

worked for the moment...
Thanks for that

so maybe can anyone give the answer if this is a valid solution?

dolec

  • Beginner
  • *
  • Posts: 21
Re: Backend "Add/Update User Information" problem with mysqli
« Reply #3 on: March 03, 2011, 19:07:18 pm »
Now it works for me in backend but during registration it doesn't store any value ? But it registers user? I dont see any error in front? What do i have to change more?

lindapowers

  • Full Member
  • ***
  • Posts: 1335
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: Backend "Add/Update User Information" problem with mysqli
« Reply #4 on: March 15, 2011, 05:31:44 am »
Hello, this happenes to me when in the backend I try to change the user group for a user or any update for users, please solution for this?

fordiy

  • Beginner
  • *
  • Posts: 12
Re: Backend "Add/Update User Information" problem with mysqli
« Reply #5 on: November 09, 2011, 03:26:37 am »
Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in \libraries\joomla\database\database\mysqli.php on line 210
This also happened after checkout succeed. Any one knows how to solve it?

The vm version: VirtueMart 1.1.9 stable
Joomla version: 1.5.24