Jump to content

Procode

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Procode's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [quote author=ToonMariner link=topic=117925.msg481493#msg481493 date=1165629393] using define will make a constant which is available anywhere - so you don't need the $smarty-> once you have defined it you can access it anywhere. (good practice to use uppercase for constants - helps you identify them in your code) [/quote] Can you give an example please? Do you mean do this [code] $smarty = new Smarty(); DEFINE('SMARTY', $smarty); [/code] Then inside a class function i do[code]SMARTY->blah();[/code] Elaborate a little more please.
  2. Ok what i want to do is define one variable and use it throughout the whole class and it's functions. Say it's smarty. How can i do[code]$smarty = new Smarty();[/code] once and use it regulary throughout my functions in the class without having to define it every time in every function? Example: Somehow i define smarty and then [code]class MyClass{     function MyFunction(){           $smarty->define('var', $var);     } }[/code]
  3. I used IPB many times before and never had any hacking problems. I think it's great software.
  4. What am i missing? My MySQL class code: [code]function assoc_array($sql){ $this->do_connect(); $sql_result = mysql_query($sql) or die(mysql_error()); if (!$sql_result)         {             $sql_error = mysql_error();             echo "<br>";             echo "<p>".$this->mysql['gen_error']."</p>";              return(false);         }         else         {             $info = mysql_fetch_assoc($sql_result);             return ($info);         } [/code] And in my actual class the code is: [code]function members_main(){ $smarty = new Smarty(); $mysql = new mysql(); $sql = "SELECT * FROM `user` WHERE username = '".$_SESSION['user']."' LIMIT 1"; $info = $mysql->assoc_array($sql); $smarty->assign('full_name', $info['name']); $smarty->assign('username', $info['username']); $smarty->assign('email', $info['email']); } [/code] it basicly shows up blank in smarty, means it doesnt work. Whats wrong? The session does work i checked.
  5. It surely is. I doubt anyone is going to do it for free tho.
  6. I dont understand, can you give an example?
  7. Ok i am trying assign a var to smarty though my class. Here is the code: [code]function members_main(){ $smarty = new Smarty(); $sql = "SELECT * FROM `user` WHERE username = '".$_SESSION['user']."' LIMIT 1"; $mysql = new mysql(); $info = $mysql->assoc_array($sql); $smarty->assign('name', $_SESSION['user']); } function member_page(){ $smarty = new Smarty(); switch($_GET['do']){ default: $this->members_main(); $smarty->display('main.members.tpl'); break;[/code] Where you see [code]$this->members_main();[/code] if i replace that with [code]$smarty->assign('name', $_SESSION['user']);[/code] It works fine. But if i do it through [code]$this->members_main();[/code] it doesn't work. What am i doing wrong?
  8. Sorry i didn't mention that before i started my class i have [code]include("config.php"); //Global mysql variable. global $mysql;[/code]
  9. Sorry if it's noobish but i am just learning classes and i just can't get this fixed. Basicly i wrote a mysql class and now have hell of errors saying it does not let me connect to the database, is it me or am i doing something wrong. I use WAMP so i use root for username... no password, localhost and db name is correct as well. Here is the MySQL class.(part of it) [code]class mysql { //MySQL var var $mysql = array(); //MySQL settings. function settings(){ //MySQL settings. $this->mysql['host'] = $mysql['host']; $this->mysql['user'] = $mysql['user']; $this->mysql['pass'] = $mysql['pass']; $this->mysql['dbname'] = $mysql['dbname']; //MySQL errors. $this -> mysql['con_error'] = "<b>MySQL encountered a severe error while trying to connect to the host</b>n";         $this -> mysql['db_error'] = "<b>MySQL encountered a severe error while trying to use the database</b>n";         $this -> mysql['gen_error'] = "<b>MySQL Error: <b>Due to a database error this page cannot be displayed</b>n"; } //MySQL connect function. function do_connect(){ $this->settings(); $connect = mysql_connect($this->mysql['host'], $this->mysql['user'], $this->mysql['pass']); $db = mysql_select_db($this->mysql['dbname']); if(!$connect){ echo "<br>"; echo $this->mysql['con_error']; }elseif(!$db){ echo "<br>"; echo $this->mysql['db_error']; } } //MySQL query function function sql_run($sql){ $this->do_connect(); $res = mysql_query($sql); if(!$res){ echo "<br>"; echo $this->mysql['db_error']; }else{ return($res); } } //MySQL mysq_num_rows function. function num_rows($sql){ $this->do_connect(); $now = $this->sql_run($sql); $res = mysql_num_rows($now); if(!$res){ echo "<br>"; echo $this->mysql['db_error']; }else{ return $res; } }[/code] Please help, what am i doing wrong?
  10. Just everytime that page loads, check what banner it is and add +1 to it's views.
  11. [quote author=ober link=topic=115268.msg469400#msg469400 date=1163736346] www.ajaxfreaks.com would be a good place... other than that, read some of the threads around here and try a few things.  [/quote] Thanks, i didnt think of that :P
  12. I am getting fairly good at php lately so i want to learn ajax/javascript as well. Where can i start? Any recomendations?
  13. Okay someone helped me at the other forum, thank you tho.
×
×
  • 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.