i guess im doing something wrong because it isn't working =/
code:
PHP Code:
$this->db->query("UPDATE ".TABLE_PREFIX."users SET items='".$this->mybb->user['items']."'
\n\n '".$this->db->escape_string($itemarray['name'])."' '".$this->db->escape_string($itemarray['download'])."',
money=money-".intval($itemarray['price'])." WHERE uid='".intval($this->mybb->user['uid'])."'");
|
Well, firstly, the SQL query is just, erm, totally wrong... I don't know what you're trying to do.
Are you trying to update the table with $itemarray?
MyBB has an update function for that...
PHP Code:
for($i=0;$i<count($itemarray);$i++)
$itemarray[$i] = $this->escape_string($itemarray[$i]);
$this->update_query(TABLE_PREFIX."users", $itemarray);
|
I don't know where you want to place the new line, so I cannot help you there.
Also, I believe the MySQL table's field must be set to TEXT, as opposed to VARCHAR to accept newlines... (not certain though).
no no no, the sql part is ok, everything works, i declared the $this and the itemarray, everythign is ok, but the \n is not working XD, im changing from VARCHAR to TEXT then.
Actually, from what I can tell, your SQL doesn't make sense...
maybe because you don't know what i want to do lol.
also, im not using that anymore, but damn it's not working with TEXT instead of VARCHAR.
New code:
PHP Code:
$items_array = array (
"items" => "'".intval($mybb->mybb->user['items'])."' \n\n '".$this->db->escape_string($itemarray['name'])."' \n '".$this->db->escape_string($itemarray['download'])"'",
"money" => "'".intval($mybb->mybb->user['money'])."'-'".intval($itemarray['price'])"'",
);
$where_items = "uid='".intval($this->mybb->user['uid'])."'";
$db->update_query(TABLE_PREFIX."users", $items_array, $where_items);
|
i get this error from mysql:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /www/freeweb7.com/p/e/r/perfectpredicament/htdocs/forums/inc/class_shop.php on line 109
(the line 109 and 110 is the
"items" => "'".intval($mybb»mybb»user['items'])."' \n\n '".$this»db»escape_string($itemarray['name'])."' \n '".$this»db»escape_string($itemarray['download'])"'",
"money" => "'".intval($mybb»mybb»user['money'])."'-'".intval($itemarray['price'])"'",
Pirata Nervo Wrote:
PHP Code:
"'".intval($mybb->mybb->user['items'])."' \n\n '".$this->db->escape_string($itemarray['name'])."' \n '".$this->db->escape_string($itemarray['download'])"'"
|
Uhh, erm...
The thing is, that's not a string.
You're putting the newline characters,
outside of the string, which makes no sense.
(also, double quoting, wrong PHP syntax etc etc)
Try this:
PHP Code:
global $mybb;
$items_array = array (
"items" => intval($mybb->user['items'])."\n\n".$this->escape_string($itemarray['name'])."\n".$this->escape_string($itemarray['download']),
"money" => intval($mybb->user['money'])." - ".intval($itemarray['price']),
);
$where_items = "uid='".intval($mybb->user['uid'])."'";
$this->update_query(TABLE_PREFIX."users", $items_array, $where_items);
|
Note that I'm presuming the code sample exists within /inc/db_mysql(i).php - that is, $this represents the $db object.
thanks, no errors on that lines now, but this is how it should be: (the $this isn't the $db object)
PHP Code:
$items_array = array (
"items" => intval($this->mybb->user['items'])."\n\n".$this->db->escape_string($itemarray['name'])."\n".$this->db->escape_string($itemarray['download']),
"money" => intval($this->mybb->user['money'])." - ".intval($itemarray['price']),
);
$where_items = "uid='".intval($mybb->user['uid'])."'";
$db->update_query(TABLE_PREFIX."users", $items_array, $where_items);
|
error on line 114 ($db»update_query(TABLE_PREFIX."users", $items_array, $where_items); )
Fatal error: Call to a member function update_query() on a non-object in /www/freeweb7.com/p/e/r/perfectpredicament/htdocs/forums/inc/class_shop.php on line 114
Oh I see what it is. You have a class, which has a copy of a global class declared privately. double you tee eff?
You should just use the global object - much neater, and better.
Ah well.
Change the $db line to $this»db then.
i didn't make the plugin, I'm modifying it, well almost everything was modified lol.
but damn i forgot to change that one ! lol thanks
but still not working lol
this is my sql part to add the items column
PHP Code:
$db->query("ALTER TABLE `".TABLE_PREFIX."users` ADD `items` TEXT NOT NULL ;");
|
Pirata Nervo Wrote:
PHP Code:
$db->query("ALTER TABLE `".TABLE_PREFIX."users` ADD `items` TEXT NOT NULL ;");
|
Either change it to $this»db, or use
global $db;