SELECT query giving error
I don't know what could be wrong with this. But I get an "invalid mysql_fetch_array()" on lines 148, 152, and 156 of a script I'm righting. I've tried changing it to fetch_field() and fetch_assoc() and it still doesn't work.
<?php
if ($action == \"store\") {
// Get Items For Sale
$sitems = $DB_site->query_first(\"SELECT * FROM rpg_items WHERE type='item'\");
$sweapons = $DB_site->query_first(\"SELECT * FROM rpg_items WHERE type='weapon'\");
$sarmor = $DB_site->query_first(\"SELECT * FROM rpg_items WHERE type='armor'\");
// Get User Gil
$gil = $DB_site->query_first(\"SELECT gil FROM user WHERE userid='$bbuserinfo[userid]'\");
// Sale bits
// Weapons
while($weapons = mysql_fetch_array($sweapons)) { // Line 148
eval(\"\$wdisp = \\"\".gettemplate(\"rpg_store_weaponbit\").\"\\";\");
}
// Armor
while($armor = mysql_fetch_array($sarmor)) { // Line 152
eval(\"\$adisp = \\"\".gettemplate(\"rpg_store_armorbit\").\"\\";\");
}
// Items
while($items = mysql_fetch_array($sitems)) { // Line 156
eval(\"\$idisp = \\"\".gettemplate(\"rpg_store_itembit\").\"\\";\");
}
eval(\"dooutput(\\"\".gettemplate('rpg_main_store').\"\\");\");
}
?>
http://www.anitrade.net/necrotic/vb/rpg.php?s=&action=store
Any idea how to fix it?
[James Logsdon]
Mark Hensler posted this at 20:48 — 28th October 2002.
He has: 4,048 posts
Joined: Aug 2000
In vBulletin, $db->query_first returns the array of the first result.
You see exactly what it does in ~admin/db_mysql.php
<?php
if ($action == \"store\") {
// Get Items For Sale
$sitems = $DB_site->query(\"SELECT * FROM rpg_items WHERE type='item'\");
$sweapons = $DB_site->query(\"SELECT * FROM rpg_items WHERE type='weapon'\");
$sarmor = $DB_site->query(\"SELECT * FROM rpg_items WHERE type='armor'\");
// Get User Gil
$gil = $DB_site->query_first(\"SELECT gil FROM user WHERE userid='$bbuserinfo[userid]'\");
// Sale bits
// Weapons
while($weapons = $DB_site->fetch_array($sweapons)) { // Line 148
eval(\"\$wdisp = \\"\".gettemplate(\"rpg_store_weaponbit\").\"\\";\");
}
// Armor
while($armor = $DB_site->fetch_array($sarmor)) { // Line 152
eval(\"\$adisp = \\"\".gettemplate(\"rpg_store_armorbit\").\"\\";\");
}
// Items
while($items = $DB_site->fetch_array($sitems)) { // Line 156
eval(\"\$idisp = \\"\".gettemplate(\"rpg_store_itembit\").\"\\";\");
}
eval(\"dooutput(\\"\".gettemplate('rpg_main_store').\"\\");\");
}
?>
Mark Hensler
If there is no answer on Google, then there is no question.
necrotic posted this at 21:03 — 28th October 2002.
He has: 296 posts
Joined: May 2002
Ah, thanks
How would I return all columns? All I get is the first column. There are 8 columns: id,name,price,attack,defense,special,forw,type.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.