vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Need help with a Mysqi problem using a mod (https://vborg.vbsupport.ru/showthread.php?t=315024)

HM666 10-23-2014 03:39 AM

Need help with a Mysqi problem using a mod
 
Before someone says "Go post in the thread that the original mod is in for help..." please note that the member who created the mod I'm about to post about has not been online since October 4 and their PM box is full as well as they are obviously not providing support for their mod.

The server has been recently upgraded from PHP 5.3 to PHP 5.4.33 and we are running vBulletin 4.2.2 P1. We are also running MySQL 5.5.37 if that helps any.

I'm using a mod called Easy Forms, some of you maybe familiar with it. Its found here: https://vborg.vbsupport.ru/showthrea...34385&page=128

I'm getting this error now when I try to view the form. This happens whenever I click on the button to view the form that I have created. Here is the error.

Code:

Fatal error: Cannot use object of type mysqli_result as array in /home/public_html/forum/forms.php on line 1242
The code that is contained on that line is:

Code:

$formbit['value'] = $q[$formbit[id]];
I am posting the results of the form to a forum id. Please help me fix this as its a very important part of the site.

nerbert 10-23-2014 04:19 AM

Just as an experiment try doing it this way

Code:

$id = $forumbit[$id];
$forumbit['value'] = $q[$id];


HM666 10-23-2014 03:22 PM

Quote:

Originally Posted by nerbert (Post 2519814)
Just as an experiment try doing it this way

Code:

$id = $forumbit[$id];
$forumbit['value'] = $q[$id];


Thanks that did not work :(

Lynne 10-23-2014 03:44 PM

I would guess it is some code above that actual line. Since I don't know the mod at all (which is why we tell you to post in the thread), then I can't say what the actual problem is. If you google the error, you'll get things like this that may help - http://stackoverflow.com/questions/1...-mysqli-result

HM666 10-23-2014 10:08 PM

Quote:

Originally Posted by Lynne (Post 2519867)
I would guess it is some code above that actual line. Since I don't know the mod at all (which is why we tell you to post in the thread), then I can't say what the actual problem is. If you google the error, you'll get things like this that may help - http://stackoverflow.com/questions/1...-mysqli-result

No I already tried that. It was no help there is no code like that in the file. I've attached the file.

[File removed]

nerbert 10-24-2014 04:03 PM

I can't find that line of code but I think your problem is that the query returns a table , which is not quite the same thing as an array, so you have to run through the table and add values to your array. Perhaps older versions of php allowed you to fudge things a little and pretend the table is an an array but we have to be better coders in this brave new world of php 5x.

So generally you would want to do something like this:

Code:

$php_array = array();

while($results = $vbulletin->db->fetch_array( $query_result ))
{
        // add some query value to the array ....
        $php_array[] = $results[something];
}


HM666 10-24-2014 08:32 PM

Quote:

Originally Posted by nerbert (Post 2519941)
I can't find that line of code but I think your problem is that the query returns a table , which is not quite the same thing as an array, so you have to run through the table and add values to your array. Perhaps older versions of php allowed you to fudge things a little and pretend the table is an an array but we have to be better coders in this brave new world of php 5x.

So generally you would want to do something like this:

Code:

$php_array = array();

while($results = $vbulletin->db->fetch_array( $query_result ))
{
        // add some query value to the array ....
        $php_array[] = $results[something];
}


Ok thanks for the info. I'll have to see if I can figure out how to apply that to this.

EDIT: just a bit of more info...If I uninstall the hack and reinstall it fresh and then create a new form it works fine until I add questions to the form. So it must have something to do with the questions being added. Maybe its possible to put those variables into an array?

ozzy47 10-25-2014 08:05 PM

Well I guess you have four options.

1) Wait for the mod author to fix the issue.
2) Downgrade your PHP version to 5.3.
3) Uninstall/Disable the mod.
4) Pay someone to fix it by posting in the paid requests forum, https://vborg.vbsupport.ru/forumdisplay.php?f=30

HM666 10-25-2014 10:27 PM

Quote:

Originally Posted by ozzy47 (Post 2520051)
Well I guess you have four options.

1) Wait for the mod author to fix the issue.
2) Downgrade your PHP version to 5.3.
3) Uninstall/Disable the mod.
4) Pay someone to fix it by posting in the paid requests forum, https://vborg.vbsupport.ru/forumdisplay.php?f=30

Unfortunately none of those options work for me. :(

ozzy47 10-25-2014 10:28 PM

Well then there is nothing you can do then. :(

HM666 10-26-2014 06:01 AM

Quote:

Originally Posted by ozzy47 (Post 2520064)
Well then there is nothing you can do then. :(

I have posted for help on a PHP forum with that little bit of the mod. Hopefully one of them will be able to help me sort it out.

ozzy47 10-26-2014 09:12 AM

I hope so, as I have a pretty close setup to what you have and can not replicate what you are getting.

HM666 10-26-2014 01:37 PM

Quote:

Originally Posted by ozzy47 (Post 2520083)
I hope so, as I have a pretty close setup to what you have and can not replicate what you are getting.

Yeah I know, I have another client who is running this hack and they are running PHP 5.4 and vB 4.2.2 as well and it works just fine. I really think now that it may have something to do with the recent server upgrade/move for this client. The host he uses are horrible and could not set anything up to save their lives I think. I'm relatively sure that my dog could set it up better, but hey nothing I can do about that. :(

BirdOPrey5 10-29-2014 08:55 AM

I'll throw out an option.

As you are on PHP 5.4.x (and not PHP 5.5.x)

In your config.php file change from

Code:

$config['Database']['dbtype'] = 'mysqli';
to

Code:

$config['Database']['dbtype'] = 'mysql';
On the off chance regular mysql still works but mysqli does not.

Also- I have removed the file you posted. You may not redistribute whole files (or significant parts) of mods not marked as re-usable code.

HM666 10-29-2014 12:57 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2520445)
I'll throw out an option.

As you are on PHP 5.4.x (and not PHP 5.5.x)

In your config.php file change from

Code:

$config['Database']['dbtype'] = 'mysqli';
to

Code:

$config['Database']['dbtype'] = 'mysql';
On the off chance regular mysql still works but mysqli does not.

Also- I have removed the file you posted. You may not redistribute whole files (or significant parts) of mods not marked as re-usable code.

Thanks but that did nothing as it was already marked as mysql and not mysqli. :( As for the file, ok.

BirdOPrey5 10-29-2014 03:13 PM

Then did you try it as mysqli?

mysqli is the better one, if both work.

HM666 10-29-2014 08:03 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2520494)
Then did you try it as mysqli?

mysqli is the better one, if both work.

Yep since it was already in mysql I tried it as mysqli and I got the same problem. :(

nhawk 11-05-2014 01:41 PM

See my PM...

I believe it's as simple as some missing quotes.

$formbit['value'] = $q[$formbit[id]];

Should be

$formbit['value'] = $q[$formbit['id']];

HM666 11-05-2014 03:22 PM

Quote:

Originally Posted by nhawk (Post 2521477)
See my PM...

I believe it's as simple as some missing quotes.

$formbit['value'] = $q[$formbit[id]];

Should be

$formbit['value'] = $q[$formbit['id']];

Thanks but that did not work.

kh99 11-05-2014 04:08 PM

I'm thinking maybe the problem is $q. It looks like it might not be set to anything at that point (although it depends on the value of $_POST['do'], which I don't know). But I suppose it could be that before it was just an unset value generating a warning, and now something else has used it as a variable (a plugin or included vb code).

That's just a guess, but it looks like $formbit should definitely be an array at that point (unless you have a plugin using hook easy_forms_view_question_start that changes it).

HM666 11-05-2014 05:12 PM

Ok there are several if/else statements & variables that contain $_POST['do'].

Code:

if ($_POST['do'] == 'updateformresult')

$_POST['do'] = 'postform';

if ($_POST['do'] == 'postform')

if ($_POST['do'] == 'insertform')

if ($_POST['do'] == 'updateform')

if ($_POST['do'] == 'insertq')

if ($_POST['do'] == 'updateq')

if ($_POST['do'] == 'formresults_export')

if ($_POST['do'] == 'updateqorder')

if ($_POST['do'] == 'importform')

if ($_POST['do'] == 'addq')

But it seems that the 'postform' may have the most to do with this, but I'm not a PHP coder so I'm not entirely sure. Here is the code that looks about like it has to do with viewing the form:

Code:

        if (($caneditformresult && !is_member_of($vbulletin->userinfo, $caneditformresult)) AND (!$canmanageownformresults OR !$vbulletin->userinfo['userid']))
        {
                print_no_permission();
        }
        $show['edit_id'] = $id = $vbulletin->input->clean_gpc('p', 'id', TYPE_UINT);
        $fid = $vbulletin->input->clean_gpc('p', 'fid', TYPE_UINT);
        $_POST['do'] = 'postform';
        $show['editing'] = true;
        $where = "";
        if ($canmanageownformresults && !is_member_of($vbulletin->userinfo, $caneditformresult))
        {
                $where = " AND userid = '" . $vbulletin->userinfo['userid'] . "'";
        }
        $formresult = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "formresults WHERE fid = '$fid' AND id = '$id' $where");
        if (!$formresult)
        {
                $errormessage = $vbphrase[form_error_data_not_exist];
              eval(standard_error($errormessage));
        }
}
if ($_POST['do'] == 'postform')
{
        $POST_FORM = true;
        $canviewform = unserialize($vbulletin->options['canviewform']);
        if (!$canviewform OR !is_member_of($vbulletin->userinfo, $canviewform))
        {
                print_no_permission();
        }
        $fid = $vbulletin->input->clean_gpc('p', 'fid', TYPE_UINT);
        if (empty($fid))
        {
                $errormessage = $vbphrase[form_error_not_existing_form];
              eval(standard_error($errormessage));
        }
        $posthash = $vbulletin->input->clean_gpc('p', 'posthash', TYPE_NOHTML);
        $poststarttime = $vbulletin->input->clean_gpc('p', 'poststarttime', TYPE_NOHTML);
        $hiddenfield1 = $vbulletin->input->clean_gpc('p', 'hiddenfield1', TYPE_NOHTML);
        $hiddenfield2 = $vbulletin->input->clean_gpc('p', 'hiddenfield2', TYPE_NOHTML);
        $hiddenfield3 = $vbulletin->input->clean_gpc('p', 'hiddenfield3', TYPE_NOHTML);
        $complete = true;
        $incompleteqs = array();
        $iqs = array();
        $form = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "forms WHERE fid = '$fid'");
        if (!$form)
        {
                $errormessage = $vbphrase[form_error_not_existing_form];
              eval(standard_error($errormessage));
        }
        ($hook = vBulletinHook::fetch_hook('easy_forms_post_form_start')) ? eval($hook) : false;
        if ($form[submitlimitperuser] >= 1 && !$show['editing'])
        {


kh99 11-05-2014 06:28 PM

Well, you'd have to know the actual value of $_POST['do'] when the error happens. You say that this happens when you click on a button that you created? Then if that button isn't submitting a form, $_POST['do'] won't have a value. That could be the problem - maybe it's not meant to be used that way. Maybe you'd have to submit a form with some data for it to work.

But really this has gotten in to helping with a mod, and that shouldn't be done in this forum (my fault, I should have said that before). We could just continue in the mod thread, if anyone else has anything to post.

bridge2heyday 11-05-2014 07:41 PM

Did you put any plugins at hook location easy_forms_view_question_start ?

ozzy47 11-05-2014 07:46 PM

Please continue this in the mods thread, this is not the proper place for discussing the mod. :)

HM666 11-06-2014 02:29 AM

This has been solved thanks all for your help.

squidsk 11-06-2014 02:02 PM

What was the solution so that if others run into the problem they can solve it?

ozzy47 11-06-2014 03:03 PM

Quote:

Originally Posted by squidsk (Post 2521638)
What was the solution so that if others run into the problem they can solve it?

Check in the modifications thread for the solution. :)

HM666 11-06-2014 03:44 PM

Quote:

Originally Posted by ozzy47 (Post 2521640)
Check in the modifications thread for the solution. :)

Yeah what he said....lol


All times are GMT. The time now is 12:14 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01237 seconds
  • Memory Usage 1,815KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (12)bbcode_code_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (28)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete