Hello,

I know nothing about PHP and this error has come up and I've been researching for days and have tried just about everything. Hopefully, I've given you enough information, but can you tell me why this line:

$row2  = mysql_fetch_assoc($res); 

is the one called up in the following error?

''Error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource... ''

function wl_cart_transfer(){

            global $OPTION,$customerArea;

            $table  = is_dbtable_there('wishlist');
            $wid    = (int) trim($_POST['transfer_wl_item']);           //change.9.9
            $qStr   = "SELECT * FROM $table WHERE wid = $wid LIMIT 0,1";
            $res    = mysql_query($qStr);
            $row    = mysql_fetch_assoc($res);

            $extraSQL = $this->attributesExtraSql($row);

            $table  = is_dbtable_there('inventory');
            $itemID = trim($row['item_id']);
            $qStr   = "SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1";    
            $res    = mysql_query($qStr);
            $row2   = mysql_fetch_assoc($res);  
            $stock  = (int) $row2['amount'];

            if($OPTION['wps_track_inventory'] == 'not_active'){
                $stock = 100000;
            }
            else {
                $table  = is_dbtable_there('inventory');
                $itemID = trim($row['item_id']);
                $qStr   = "SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1";    
                $res    = mysql_query($qStr);
                $row2   = mysql_fetch_assoc($res);  
                $stock  = (int) $row2['amount'];    
            }

Thanks in advance.

Member Avatar for diafol

> I know nothing about PHP

Perhaps your query is wrong.

> I know nothing about PHP

Perhaps your query is wrong.

I've been playing around with the query and can't seem to find out what's wrong with the statement.

Member Avatar for diafol

The query is MYSQL.
Paste the query into phpmyadmin and see what it gives.

The query is MYSQL.
Paste the query into phpmyadmin and see what it gives.

Yes, I've done that and it does pull the query as an error, but I don't know how to fix it...(again, I know nothing, this was code written by someone else and I can't get help there).

qStr = "SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1";

MySQL said: Documentation
#1064 - 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 '$qStr = "SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1' at line 1

Thanks for your responses.

Member Avatar for diafol

SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1

would not work in phpmyadmin anyway as it contains php variables (bold).

do this in your php file:

echo "SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1";

and see what it gives you.
This is what you paste into your phpmyadmin window. I suspect that one or more of these vars isn't set.
echo "

SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1

would not work in phpmyadmin anyway as it contains php variables (bold).

do this in your php file:

echo "SELECT amount FROM $table WHERE $extraSQL ID_item = '$itemID' LIMIT 0,1";

and see what it gives you.
This is what you paste into your phpmyadmin window. I suspect that one or more of these vars isn't set.
echo "

Fixed it!...it was this line: $extraSQL = $this->attributesExtraSql($row); it needed to say row2.

Member Avatar for diafol

Great - please make this thread solved - there's a little link below the edit box. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.