News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Calling function error

Started by The Wizard, September 17, 2012, 12:32:31 PM

Previous topic - Next topic

The Wizard

Hello:

I'm having a issue calling a function. Below is the error I'm getting

QuoteYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id_member=1
LIMIT 1' at line 3
File: /Sources/Subs-Wizards_Item_Gallery.php
Line: 40

Here is my code:

QuoteSubs-Wizards_Item_Gallery.php

<?php

// place this file in the Sources file

if (!defined('SMF'))
        die(
'Hacking attempt...');

function
wizard_add_hook(&$actionArray) {
         
$actionArray['wizard'] = array('Subs-Wizards_Item_Gallery.php', 'wizard');
}
 


function
wizard ()
{
   global
$context;

   
loadTemplate('wizard_item_gallery'); // this command loads the template file (template.wizard_item_gallery.php)

}
// End of Function wizard bracket

// Function One: Show all Images user has in Gallery

function One()

{

// Globals
global $smcFunc, $txt, $user_info, $context, $db_prefix, $boardurl;

// Get the user's information from the database

$request1 = $smcFunc['db_query']('','
          SELECT wizard
          FROM{db_prefix}members
          WHERE id_member={int:current_member}          
  LIMIT 1'
,
          array(
        'current_member' => $user_info['id'],
)
);

// Populate the array

while($row=$smcFunc['db_fetch_assoc']($request1)){
if(empty(
$row))
  return
false;

$wizard2 = explode(',', $row['wizard']);

}
// End of While bracket

echo '<center><h3>', $context['wiz0'], '</h3></center>';

// Show Users Items in a Gallery

$i = 0;

echo
'<center><table><tr>';

foreach(
$wizard2 as $image)

{

// Ignore Items the user does not have

if (empty($image))
   continue;

$i++;

// Display Items the user has

echo '<td><a href="?run=one&a='.$image.'"><img src="', $boardurl, '/Sources/shop/wizards_item_image_gallery/small/',$image,'.png" border=0></a></td>';

//To change the number of colums displayed across just change $wiz to the number you need to display

$wiz = 6;

if(
$i % $wiz ==0)
echo
'</tr><tr>';

}
// End of foreach bracket

echo '</tr></table></center>';

}
// End of Function One bracket


?>


Quotewizard_item_gallery_template.php

<?php

function template_main () // The name of this function can be defined elsewhere, but to keep it simple for now, let's say that it is always template_main
{
 global
$context, $boardurl, $txt;
 
echo '<html>
     <head>'
;
 
//  All links on the page will be non-underlined
   
echo '
         <style type="text/css">
         a { text-decoration:none }
         </style>'
;
 
echo'  
         </head>
         <body>
 <center>
         <table border=5>
     <tr>
 <td>
 <b>SMF Shop Home</b><br><br>
 <a href="'
. $boardurl . '/index.php?action=shop">Shop Home</a><br>
         <a href="'
. $boardurl . '/index.php?action=shop;do=buy">Buy Stuff</a><br>
         <a href="'
. $boardurl . '/index.php?action=shop;do=inv">Your Inventory</a><br>
         <a href="'
. $boardurl . '/index.php?action=shop;do=sendmoney">Send Money to Someone</a><br>
         <a href="'
. $boardurl . '/index.php?action=shop;do=senditems">Send an Item to Someone</a><br>
         <a href="'
. $boardurl . '/index.php?action=shop;do=invother">View Other Members Inventory</a><br>
         <a href="'
. $boardurl . '/index.php?action=shop;do=bank">Bank</a><br>
         <a href="'
. $boardurl . '/index.php?action=shop;do=trade">Trade Center</a><br>
         <a href="'
. $boardurl . '/index.php?action=wizard">Remove Item from Gallery</a><br>
 </td>
 <td>'
;  
 
// Simple Text Intro

echo '<center><h3>', $txt['wiz5'], '<br>', $txt['wiz6'], '<br>', $txt['wiz7'], '</h3></center>';

   
One (); // Show all Images user has in Gallery

echo '<center><h3>', $txt['wiz0'], '</h3></center>';

   
//
echo '</td>
         <td><img src="'
. $boardurl . '/Themes/default/images/wizard2.gif"></td>
     </tr>
         </table>
 </center>
         </body>
         </html>'
;
}


?>


Note: I am in the process of cleaning up the code

Wiz

MrPhil

Try adding a space after FROM. I think you're ending up with FROMsmf_members, which MySQL may not be able to figure out.

The Wizard

BINGO!!

Thanks MrPhill for spotting that!

Advertisement: