WebsiteBaker Community Forum
WebsiteBaker Support (2.13.x) => General Help & Support => Topic started 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 :-().
-
Sorry, forgot to include the URL of the problematic site:
www.embajadadedinam arca.org
And line 247 has this:
<?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?
-
Hi, can be the solution is easy.
The part mysql_ needs an i.
Try:
mysqli_db_query
-
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):
-
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:
<?php $result999 = mysqli_db_query("$base_datos","select * from tb_art_cat where id_categoria_articulo <> 1 order by id_categoria_articulo asc"); ?>
-
Sorry again, I didn't copy the code provided by the AI, this is what worked (only adding the "i" didn't):
<?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.
-
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
<?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
$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
"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
"SELECT * from `tb_art_cat` WHERE `id_categoria_articulo` <> 1 ORDER BY `id_categoria_articulo` ASC");
-
Thank you for your help!!! :-)