News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

Error when trying to read personal messages

Started by JoshuaD, March 09, 2021, 04:18:02 AM

Previous topic - Next topic

JoshuaD

If any user tries to load a personal message (index.php?action=pm) they get the following error:

QuoteWrong value type sent to the database. Integer expected. (id_msg)

I'm guessing (hoping) this is an easy fix, where somewhere in my theme file, id_msg is being sent as a string when it should be sent as an int.

Unfortunately, I can't figure out where this is happening. Based on the code in index.php, I tried looking for the string "id_msg" in Sources/PersonalMessage.php, but I didn't see that exact variable name (the variable name must not match the column name) and I'm not sure which line this is happening in.

I also tried looking in error_log, but there is no entry for this error there.

Any suggestion on how to fix this? Thanks in advance!

Edit: I found the error logs in the admin panel, and it gives me a file and a line number:

File: ../Sources/Subs.php
Line: 2528


2524    } else if ($id_msg !== '') {
2525       $request = $smcFunc['db_query']('',
2526          'SELECT * FROM {db_prefix}rolls WHERE id_msg = {int:id_msg}',
2527          array ( 'id_msg' => $id_msg )
2528       );
2529       $dbRolls = array();
2530       while ($row = $smcFunc['db_fetch_row']($request)) {
2531          array_push($dbRolls, json_decode($row[2]));
2532          $smcFunc['db_free_result']($row);
2533       }


I printed the value of $id_msg here and it is "pm5".

I'll start messing around, but if you know how to fix this, please help! Thanks

JoshuaD

I added this line:

    $id_msg = str_replace("pm", "", $id_msg);

just before the database request, and it solved the problem.  The value of $id_msg was "pm5" and it seems to want to be just '5'.  Is this an OK edit to make? Any concerns with doing it?

Kindred

well, I would be concerned about how id_msg got set to something other than an integer in the first place....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Oldiesmann

That would be due to a mod of some sort because SMF doesn't have a "rolls" table

Advertisement: