Multiple id numbers
Moderator: General Moderators
Multiple id numbers
Been reading all over the web for days and haven't found a simple solution.
I took this part of a working file
$res = mysql_query("SELECT itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." ORDER BY itemid ASC");
And changed it to this
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND itemid = 23");
Great, now I can see this one item on my inventory !
But what I really need it to do is to show x amount of id#s in my inventory
so I tried the simple approach
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND itemid = 23",24,25,26);
It does not work even after trying it 10 different ways ...
itemid =("23", "24", "25", "26"); and so on
Any help would be highly appreciated !
I took this part of a working file
$res = mysql_query("SELECT itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." ORDER BY itemid ASC");
And changed it to this
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND itemid = 23");
Great, now I can see this one item on my inventory !
But what I really need it to do is to show x amount of id#s in my inventory
so I tried the simple approach
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND itemid = 23",24,25,26);
It does not work even after trying it 10 different ways ...
itemid =("23", "24", "25", "26"); and so on
Any help would be highly appreciated !
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Multiple id numbers
You either need full expressions ORed together or use IN, or BETWEEN if it is a range:
[text]AND (itemid = "23" OR itemid = "24" OR itemid = "25" OR itemid = "26")[/text]
--or--
[text]AND itemid IN ("23", "24", "25", "26")[/text]
--or--
[text]AND (itemid BETWEEN 23 AND 26)[/text]
[text]AND (itemid = "23" OR itemid = "24" OR itemid = "25" OR itemid = "26")[/text]
--or--
[text]AND itemid IN ("23", "24", "25", "26")[/text]
--or--
[text]AND (itemid BETWEEN 23 AND 26)[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Multiple id numbers
Thanks for a fast reply
Although it doesnt like none of them:p
unexpected T_LNUMBER
Ill share more of the file if it helps any, Thanks again
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND itemid = 26");
while ($row = mysql_fetch_array($res)) {
$miscitems[] = $row[itemid];
$indexid[$row[itemid]] = $row[id];
Although it doesnt like none of them:p
unexpected T_LNUMBER
Ill share more of the file if it helps any, Thanks again
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND itemid = 26");
while ($row = mysql_fetch_array($res)) {
$miscitems[] = $row[itemid];
$indexid[$row[itemid]] = $row[id];
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Multiple id numbers
That's a PHP error. What is the full code and what line number does the error state? Aren't you missing a closing } in the while loop?Scoobs wrote:Thanks for a fast reply
Although it doesnt like none of them:p
unexpected T_LNUMBER
Ill share more of the file if it helps any, Thanks again
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND itemid = 26");
while ($row = mysql_fetch_array($res)) {
$miscitems[] = $row[itemid];
$indexid[$row[itemid]] = $row[id];
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Multiple id numbers
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me[id]) ." AND (itemid = "23" OR itemid = "24" OR itemid = "25" OR itemid = "26");
was the line of error with each change I made
was the line of error with each change I made
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Multiple id numbers
Code: Select all
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me['id']) ." AND (itemid = '23' OR itemid = '24' OR itemid = '25' OR itemid = '26'");mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Multiple id numbers
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/kingdomr/public_html/research/inventoryEXP.php on line 178
This is line 178... while ($row = mysql_fetch_array($res)) {
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me['id']) ." AND (itemid = '23' OR itemid = '24' OR itemid = '25' OR itemid = '26'");
while ($row = mysql_fetch_array($res)) {
$miscitems[] = $row[itemid];
$indexid[$row[itemid]] = $row[id];
Also I pm you .
This is line 178... while ($row = mysql_fetch_array($res)) {
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = ". sqlesc($me['id']) ." AND (itemid = '23' OR itemid = '24' OR itemid = '25' OR itemid = '26'");
while ($row = mysql_fetch_array($res)) {
$miscitems[] = $row[itemid];
$indexid[$row[itemid]] = $row[id];
Also I pm you .
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Multiple id numbers
Code: Select all
$res = mysql_query("SELECT id, itemid FROM useritems WHERE userid = '". sqlesc($me['id']) ."' AND (itemid = '23' OR itemid = '24' OR itemid = '25' OR itemid = '26')") or die(mysql_error());mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Multiple id numbers
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1'' AND (itemid = '23' OR itemid = '24' OR itemid = '25' OR itemid = '26')' at line 1
line 1 is just
<?php
line 1 is just
<?php
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Multiple id numbers
You need to get your quotes sorted out. What I posted last should work if you copy and paste it. It may also depend on what $me['id'] is and what sqlesc() does to it.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Multiple id numbers
Well thanks for the help, will continue to try everything, till I get it