MantisBT - ATutor
View Issue Details
0005495ATutorInstallationpublic2014-07-21 09:192016-01-01 09:59
normalminorhave not tried
0005495: real_escape_string() fails on install (mysql 5.1.66)
There have been a couple report of the following error
Fatal error: Call to a member function real_escape_string() on a non-object in /home/u241584689/public_html/include/lib/ on line 141

Test the install on [^]
No tags attached.
related to 0005510closed greg Installation fails with a fatal error if the database to be created already exists 
png wampATutorInstallation.png (19,669) 2014-10-03 18:27
Issue History
2014-07-21 09:19gregNew Issue
2014-07-21 09:19gregStatusnew => assigned
2014-07-21 09:19gregAssigned To => greg
2014-07-22 12:40gregNote Added: 0006846
2014-07-24 20:52gregNote Added: 0006847
2014-07-25 13:48gregNote Added: 0006848
2014-07-25 14:33gregNote Added: 0006849
2014-07-26 12:11gregNote Added: 0006850
2014-08-06 17:58gregNote Added: 0006852
2014-08-06 17:58gregStatusassigned => acknowledged
2014-08-08 18:44gregSummaryreal_escape_string() fails on install => real_escape_string() fails on install (mysql 5.1.66)
2014-08-21 19:52gregRelationship addedrelated to 0005510
2014-10-03 14:49gregNote Added: 0006998
2014-10-03 18:27gregFile Added: wampATutorInstallation.png
2014-10-04 10:30gregNote Added: 0006999
2014-10-04 10:54gregNote Added: 0007000
2014-10-04 13:58gregNote Added: 0007001
2014-10-04 13:58gregChangeset attached => ATutor master 81f968fc
2014-10-09 18:23gregSVN Revision# => master 81f968fc
2014-10-09 18:23gregNote Added: 0007002
2014-10-09 18:23gregStatusacknowledged => resolved
2014-10-09 18:23gregFixed in Version => 2.2
2014-10-09 18:23gregResolutionopen => fixed
2015-09-18 19:43anonymousSVN Revision#master 81f968fc =>
2016-01-01 09:59gregNote Added: 0007179
2016-01-01 09:59gregStatusresolved => closed

2014-07-22 12:40   
Also see: [^]
2014-07-24 20:52   
This issue is the result of the following query failing in the create_and_switch_db() function in include/install/

$row = queryDB($sql, array($db_name));

It may be due to the use of back quotes, which is required for this query that is used to test the DB character set for UTF-8 collation.

This does not happen on all systems. In this case mysql -v = 5.1.66, tested on

For a temporary workaround, the else block that the query appears in can be safely removed/commented if the DB is known to be UTF-8, then install will finish successfully.

Continuing to look for a solution...
2014-07-25 13:48   
The backtick issue does seem to be the problem. Reviewing the fixes in mysql 5.1.67, (Bug #66550, Bug #14548159, Bug #29422, Bug #11746883) [^]
2014-07-25 14:33   
Possible workaround:

mysql_set_charset('utf8',$connection); [^]
2014-07-26 12:11   
Create database privileges are required to run SHOW CREATE DATABASE
2014-08-06 17:58   
There does not appear to be a satisfactory solution to this issue that does not involve some significant recoding. This will have to wait until after ATutor 2.2 is released
2014-10-03 14:49   
notes: alex
just reinstalled and could not reproduce
but then I decided to change port to 3310 insteead of 3306 in mamp
and got white screen on my 2.2 step where people have errors
on step 2 you specify mysql port but even when I put 3310 there explicitely
still blank
although do not want to stir us into wrong direction
if the users are tecksavvy I would STRONGLY recommend to double check that if there is atutor database already, drop it and then redo installation
whenever there are issues with installation and there is a partial result in mysql, installation would always go sideways for me (at least before)
I also would suggest droping a database if one already exists for installation scripts
2014-10-04 10:30   
I was able to reproduce the problem by creating the database before installing. We're back to the original issue in the second comment above:

$row = queryDB($sql, array($db_name)); is not able to run the query. The query runs fine if manually run in mysql. Sounds like a separate function may be required for this particular query.

Any ideas?
2014-10-04 10:54   
We do need to accomodate an existing database, so can't delete it on installation. Some hosts do not provide the create database privilege, and users must manually create the database through thier control panel.
2014-10-04 13:58   
created a bundle that hopefully resolves this issue [^]
2014-10-09 18:23   
Added queryDButf8() to to handle the installer's check for the existance of a database before creating one, include/install/

Also fixed up step 3 and 6 in the install, to fix the mismtached num of parameters sql error.
2016-01-01 09:59   
closed for 2.2.1