WebsiteBaker Community Forum

WebsiteBaker Support (2.13.x) => General Help & Support => Topic started by: svsanchez on April 30, 2024, 06:05:42 AM

Title: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: svsanchez on April 30, 2024, 06:05:42 AM
Hello,

I am trying to upgrade several sites made in WB from 2.8.3 to 2.12 or 2.13

After running the upgrade, the backend works but the front-end shows the following message:

There was an uncatched exception
Call to undefined function mysql_db_query()
in line (247) of (/templates/round/index.php):

This happens on SOME of the sites I upgrade, while others work alright. I am leaving this one with the problem hoping that someone can tell me what the problem is in order to fix the others that are having this same issue. (I had to move to another host that still has PHP 5.6 support with the first sites showing this issue but that will only work for some time  :-().
Title: Re: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: svsanchez on April 30, 2024, 06:13:08 AM
Sorry, forgot to include the URL of the problematic site:

www.embajadadedinam arca.org

And line 247 has this:

Code: [Select]
<?php $result999 mysql_db_query("$base_datos","select * from tb_art_cat where id_categoria_articulo <> 1 order by id_categoria_articulo asc"); ?>
Which I ***THINK*** it is not part of WB?
Title: Re: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: dbs on April 30, 2024, 06:31:37 AM
Hi, can be the solution is easy.
The part mysql_ needs an i.
Try:
Code: [Select]
mysqli_db_query
Title: Re: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: svsanchez on April 30, 2024, 07:22:02 AM
Hi dbs, unfortunately it didn't work, now the error message is the same but with the "i":

There was an uncatched exception
Call to undefined function mysqli_db_query()
in line (247) of (/templates/round/index.php):
Title: Re: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: svsanchez on April 30, 2024, 07:34:59 AM
Hello again, I used AI to try and fix it, it apparently gave me the whole line and it seems that the only change made was the one suggested by dbs, not sure why it didn't work when I added the "i" the first time. Here's the apparently corrected code:

Code: [Select]
<?php $result999 mysqli_db_query("$base_datos","select * from tb_art_cat where id_categoria_articulo <> 1 order by id_categoria_articulo asc"); ?>
Title: Re: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: svsanchez on April 30, 2024, 07:39:20 AM
Sorry again, I didn't copy the code provided by the AI, this is what worked (only adding the "i" didn't):

Code: [Select]
<?php $result999 mysqli_query($conn"SELECT * FROM tb_art_cat WHERE id_categoria_articulo <> 1 ORDER BY id_categoria_articulo ASC"); ?>
Not sure if it is supposed to do the same as the code that was showing an error.
Title: Re: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: sternchen8875 on April 30, 2024, 09:51:28 AM
i've to say it like a teacher, sorry:
best solution is a switch to the WB-own $database-object, otherwhise you run from problem to problem. of course, its anything to do, but you'll love it, if everything works at the end
Here some links from our forum - in the first Link, the user define a global $database at the begin, but use the the stand-alone-solution with mysql
https://forum.WebsiteBaker.org/index.php/topic,28402.msg198930.html#msg198930
https://forum.WebsiteBaker.org/index.php/topic,30954.msg215857.html#msg215857
https://forum.WebsiteBaker.org/index.php/topic,29043.msg203946.html#msg203946

to the mysqli-problem

check at first the phpinfo, is there a own block for mysqli like this?
https://i.gyazo.com/5326a147eea466938e50b7f0fcc7bfc9.png

Code: [Select]
<?php $result999 mysqli_query($conn"SELECT * FROM tb_art_cat WHERE id_categoria_articulo <> 1 ORDER BY id_categoria_articulo ASC"); ?>


this query has two parts, the connector $conn and the Select
in step one search for the definition of the connector, in this example "$conn", the connector for mysqli is a little bit different to the simple mysql. Be sure, that the connector use now mysqli_connect instead of a simple "new mysql" or "mysql_connect"

example for mysqli
Quote
$conn = mysqli_connect("name of the host","your_db_username","your_db_password","used_database");

check and change the colored parts

Tip: php and mysql goes stricter and stricter

Quote
"select * from tb_art_cat where id_categoria_articulo <> 1 order by id_categoria_articulo asc");

for better reading, coding standards and also better work in the future, i marked some part in this example, the sql-commands are green, table-specific datas are in red
Use upper letters for the sql-commands and put every table-specific-datas between apostrophes

same code corrected
Code: [Select]
"SELECT * from `tb_art_cat` WHERE `id_categoria_articulo` <> 1 ORDER BY `id_categoria_articulo`  ASC");


Title: Re: There was an uncatched exception. Call to undefined function mysql_db_query()
Post by: svsanchez on May 03, 2024, 04:22:31 AM
Thank you for your help!!!  :-)