Jump to content

[SOLVED] Variable variable inside mysqli_query


sKunKbad

Recommended Posts

I'm having trouble with a mysql query. Specifically, I am looping through some queries, and I have a variable variable inside the query which I'm sure is causing the problem. Actually there are two variable variables.

 

Right now the error is:

Parse error: syntax error, unexpected '{', expecting ']' in C:\wamp\www\loginTest\status.inc.php on line 200

 

Here is the query:

mysqli_query($db , "UPDATE `{$type}s` SET login_hold = 0 WHERE " . $type . "_id = '{$row[{"$type" . "_id"}]}' LIMIT 1");

 

I know I'd eventually get it, but some help is appreciated.

That's what I had to do. It's weird that I could do something like this:

 

<?php
$type= "user";
$row['user_id'] = 13874;
$query = "UPDATE `{$type}s` SET login_hold = 0 WHERE " . $type . "_id = '" . $row[$type . _id] . "' LIMIT 1";
echo $query;
?>

 

but when the query is actually inserted into mysqli_query, it doesn't work anymore.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.