Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Error trying to access array offset of type INT

Asked Modified Viewed 661 times
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
asked
Senior Member

I have this same question posted on Stack Exchange but so far no answers so I thought I'd try our home team as well for help. I am working on my own home grown 'home_inventory' infusion, search scripts. A bit of history first. Here is a pic of a functioning search script output:
whisperwillow.net/MyPics/search1.jpg

As you can see everything works fine. The problem scenario is that the bottom row in the image which shows total items, items found and total cost needs to be above the main table display because if a member has 100 or more music albums and the search finds say, 37 then in order to see the total value of the found albums it would be necessary to scroll to the bottom to see it. I am trying to modify the book search script to display the way I just described. Here is a pic of the modified book search script (which partially works) and you can see that the value of found books is missing, is zero:
whisperwillow.net/MyPics/search2.jpg

Here is the code I have changed that is producing the error:
   $total1_result = dbquery("SELECT * FROM ".DB_HOME_BOOK." WHERE owner_id='".$userdata['user_id']."'");
   $num_rows = dbrows($total1_result);

      $query = $search;
      $sum = 0; THIS IS NEW
      $result = dbquery("SELECT * FROM ".DB_HOME_BOOK." WHERE owner_id='".$userdata['user_id']."' AND title LIKE '%$query%' OR author LIKE '%$query%' OR format LIKE '%$query%' OR publisher LIKE '%$query%' OR year LIKE '%$query%' OR isbn LIKE '%$query%' OR value LIKE '%$query%'");
      $nrows = dbrows($result);
         $sum += (intval($nrows['value'])); THIS IS NEW AND THE SOURCE OF THE ERROR
   if ($nrows) {
opentable($locale['his_1400']);
      MenuBook();
   echo "<br /><div align='center'><b>".$locale['his_1403']."<span style='background-color:#ffff88;color:#333;font-weight:bold;padding-left:2px;padding-right:2px'>$query</span>".$locale['his_1404']."</b></div><br>";
BELOW CODE IS NEW
   echo "<table align='center'><tr><td height='3' colspan='3'></td></tr>\n";
$formatted_value = "$".number_format( (float) $sum, 2, '.', '');
   echo "<tr><td class='srch-total' align='center'>".$locale['his_1433']."$num_rows</td><td class='srch-total' align='center'>".$locale['his_1425']."$nrows</td><td class='srch-total' align='center'>".$locale['his_1424']."$formatted_value</td></tr>\n";
   echo "<tr><td height='3' colspan='3'></td></tr></table>\n";

Where I say THIS IS NEW and BELOW CODE IS NEW it's not reall new just brought up from below the main table display coding. Any help or insights on how to properly obtain the total book value of found books would be appreciated and thanks in advance for all the help that you guys provide when you have the time.
Edited by Grimloch on 26-06-2021 20:11,
0 replies

4 posts

R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

It pointless ask about PF in forums like Stack Exchange. People on these forums always says that PF is dead or it's so bad CMS. In fact, they just tried old and bad v7 and immediately sank all new versions.

---

Just put that code to if statement to get rid of error
 
if ($nrows) {
$sum += (intval($nrows['value'])); THIS IS NEW AND THE SOURCE OF THE ERROR
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
answered
Senior Member

Makes no difference error still there and what I was really asking was if my code is correct or not because it produces no output.
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

Shuffle this,
 $sum += (intval($nrows['value'])); THIS IS NEW AND THE SOURCE OF THE ERROR
 if ($nrows) {


Something like,


if (!EMPTY($nrows['value']) && $nrows['value'] != 0) {
 $sum += (intval($nrows['value'])); THIS IS NEW AND THE SOURCE OF THE ERROR

To pull data you need to dbarray it, not only check dbrows ( $nrows = dbrows($result); )
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
answered
Senior Member

Problem solved by afoster and myself.
0 replies

Labels

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

F
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
G
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
R
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet