Customizing SMF > SMF Coding Discussion

db_fetch_row question

(1/2) > >>

The Wizard:
I'm not sure if this is the correct use or not. Does anybody know?


--- Code: ---$row_dog = $smcFunc['db_fetch_row']($result_dog);

if($row_dog['shop_Dog'] !== "") {
                echo "Cute Dog: <img src='{$boardurl}/Sources/shop/dog_images/{$row_dog['shop_Dog']}.png'><br>";[code]
--- End code ---

Arantor:
Use db_fetch_assoc not db_fetch_row.

db_fetch_row creates a numeric indexed array (0, 1, 2, 3 etc) while db_fetch_row creates an associative array. Presumably shop_Dog is a column named in your query.

The Wizard:
I tryed adding db_fech_assoc but I get the following error:

--- Quote ---Parse error: syntax error, unexpected $end in /Sources/Load.php on line 2823
--- End quote ---
Below is the function I wanted to call. Any ideas Marvin?

         

--- Code: ---function onUser () {
    global $smcFunc;
     
        $result_dog = $smcFunc['db_query']('', '

SELECT id_member, member_name, shop_Dog

FROM {db_prefix}members

WHERE id_member = {id_member}',

array(
     
              'id_member' => $message['member']['id'],
      'member_name' => $name,
  'shop_Dog' => $dog,

);

$row_dog = $smcFunc['db_fetch_assoc']($result_dog);

if($row_dog['shop_Dog'] !== "") {
                echo "Cute Dog: <img src='{$boardurl}/Sources/shop/dog_images/{$row_dog['shop_Dog']}.png'><br>";

}
--- End code ---
   

Arantor:
Not calling me Marvin would be a great start. It'd be like me calling you Rincewind.

The error is quite plain: it didn't expect the end of the file, you have a mismatch of closing brackets, not enough to match the opening brackets that you have there - and it hit the end of the file before seeing the right number of closing brackets.

Yoshi:
You forgot a bracket at the end of your function.

EDIT: Arantor beat me to it ;D

Navigation

[0] Message Index

[#] Next page

Go to full version