Slim has randomly stopped working for my mobile app

Hey all,

I’ve been running a simple mobile application fine for a while now and a few days a go, it has stopped working. I haven’t changed a single piece of code both front or back end so this is random.

I’ve checked the error logs and it seems something involving Slim is causing the issue.

It’s a huge log as i’ve only just noticed that no new users have signed up so please can someone help ASAP.

I used AJAX calls to the back-end php to contact slim and make various functions work but nothing is working.

Here is a snippet of the error:

[28-Feb-2019 23:30:35 UTC] Slim Application Error:
Type: Error
Message: Call to undefined function mysql_num_rows()
File: /home/u643930530/domains/
Line: 93
Trace: #0 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#1 /home/u643930530/domains/ call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#2 /home/u643930530/domains/ Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#3 /home/u643930530/domains/ Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#4 /home/u643930530/domains/ Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#5 /home/u643930530/domains/ Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#6 /home/u643930530/domains/ Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#7 /home/u643930530/domains/ Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#8 /home/u643930530/domains/ Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#9 /home/u643930530/domains/ Slim\App->run()
#10 {main}
View in rendered output by enabling the “displayErrorDetails” setting.

Any help will be greatly appreciated!




It looks like your provider changed the PHP version or removed the deprecated mysql_ extension.

You should change your codebase from mysql_ to mysqli_ or PDO.

Thank you for the prompt reply and comments Odan but looking at the error log more, it seems the errors aren’t just related the mysql_ extension.

I have just spoken with the providers and they did in fact change the php version which messed with my app! So all is fine now as it’s on version 5.6.

I’m new to this still so could you please explain why that would effect the functionality?

Thank you for your time!

The mysql_* extension has been removed entirely as of PHP 7.0 (released December 2015)

Until PHP 5.6 the mysql extensions works, but after your provider changed the PHP version to 7.x, all mysql_* functions are gone.

Oh I see! Thank you for the clarity.

However, I feel if my app isn’t using the most up-to-date php version, will it cause issues down the line?

Looking at my php, it all uses PDO to carry out its functions EXCEPT the php code containing the connection to my database.

Could you suggest a way to structure this code so it able to use PHP 7.******

public function connect(){

    $mysql_connect_str = "mysql:host=$this->dbhost;dbname=$this->dbname";
    $dbConnection = new PDO($mysql_connect_str,$this->dbuser, $this->dbpass);
    $dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $dbConnection;


Thank you!

For Slim I would recommend using the container (as factory) for your database connection.

You may search in in your codebase, /src/routes/customers.php Line: 93 and replace the old database code with PDO (for example).