Post Reply 
Help with textarea in html
i must know how to
Author Message
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #11
RE: Help with textarea in html
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'])."'");


12/11/2007 03:55 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #12
RE: Help with textarea in html
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).

12/11/2007 07:08 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #13
RE: Help with textarea in html
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.

13/11/2007 02:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #14
RE: Help with textarea in html
Actually, from what I can tell, your SQL doesn't make sense...
13/11/2007 03:57 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #15
RE: Help with textarea in html
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:
1
2
3
4
5
6
$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'])"'",

(This post was last modified: 13/11/2007 04:34 AM by Pirata Nervo.)
13/11/2007 04:34 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #16
RE: Help with textarea in html
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:
1
2
3
4
5
6
7
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.

(This post was last modified: 13/11/2007 04:42 AM by ZiNgA BuRgA.)
13/11/2007 04:39 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #17
RE: Help with textarea in html
thanks, no errors on that lines now, but this is how it should be: (the $this isn't the $db object)

PHP Code:
1
2
3
4
5
6
$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


13/11/2007 04:59 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #18
RE: Help with textarea in html
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.
13/11/2007 05:16 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #19
RE: Help with textarea in html
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 ;");


13/11/2007 12:05 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #20
RE: Help with textarea in html
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;
13/11/2007 03:33 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: