Jump to content

unidox

Members
  • Posts

    557
  • Joined

  • Last visited

    Never

About unidox

  • Birthday 04/12/1992

Contact Methods

  • MSN
    theprophet841@gmail.com
  • Website URL
    http://www.crux-media.com

Profile Information

  • Gender
    Male
  • Location
    NY

unidox's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. unidox

    Replace

    I have multiple \n in a string, and I need to replace it with <br />. How do I go about doing this? Preg replace?
  2. unidox

    Array

    I have an array such as: Array ( [0] => : [1] => 353 [2] => SGS|Bot-1 [3] => = [4] => #a [5] => :SGS|Bot-1 [6] => +SGS|Bot [7] => SGS|Ryan`AFK [8] => @a|TaCo [9] => SGS|Pat [10] => @U|Pat [11] => @ChanServ ) How do I go through that array, and remove a "+" or a "@" from each index only if it has one in the beginning. Thanks
  3. unidox

    Bullets

    On my website, I have a bullet, and when the text gets to big for the div, it goes down a line, and starts underneath the bullet. How do I keep the same margin as how it started?
  4. unidox

    Sorting

    I have an array like this: $array[$row] = array ( 'name' = $name, 'discount' = $discount, 'price' = $price ); Now, I have about 200 of those in that array, and im trying to sort by the discount, highest 1st. How would I go about doing that? Thanks.
  5. unidox

    Error

    Can I ask how I can improve it?
  6. unidox

    Error

    What do you mean by floored?
  7. unidox

    Error

    Could I use a global?
  8. unidox

    Error

    Well, the db is already declared inside index.php: <?php session_start( ); // exit ( $_SESSION['userId'] ); include ("../config.php"); include ("../core/coreClass.php"); include ("../core/dbClass.php"); include ("../core/userClass.php"); define (IN_SCRIPT, true); $coreClass = new coreClass ( ); $dbClass = new dbClass ( $host, $username, $password, $table ); $userClass = new userClass ( ); if ( !$userClass->checkLoggedIn( ) ) { $currentPage = "login"; } elseif ( $coreClass->getGET("page") && file_exists ( "pages/".$coreClass->getGET("page").".php" ) ) { $currentPage = $coreClass->getGET("page"); } else { $currentPage = "home"; } include ( "processors/".$currentPage.".php" ); include ( "pages/".$currentPage.".php" ); ?>
  9. unidox

    Error

    dbClass: <?php class dbClass { private $last_error; private $last_query; private $row_count; public $owner_email; public $db_host; public $db_username; public $db_password; public $db_table; public $site_dir; public $prefix; private $link; function __construct( $host, $username, $password, $table ) { $this->db_host = $host; $this->db_username = $username; $this->db_password = $password; $this->db_table = $table; $this->connect(); } function connect () { $this->link = mysql_connect($this->db_host, $this->db_username, $this->db_password); if (!$this->link) { $this->last_error = mysql_error(); return false; } if (!$this->select_table()) { return false; } return $this->link; } function select_table() { if (!mysql_select_db($this->db_table)) { $this->last_error = mysql_error(); return false; } return true; } function sql($table, $sql) { $this->last_query = "Table: " . $table . "Query: " . $sql; $row = mysql_query("SELECT * FROM `" . $prefix . $table . "` " . $sql . "") or die ( mysql_error ( ) ); if (!$row) { $this->last_error = mysql_error(); return false; } $this->row_count = mysql_num_rows($row); return $row; } function get_row($result, $type="MYSQL_BOTH") { if (!$result) { $this->last_error = "Invalid resource identifier passed to get_row() function."; return false; } if ($type == 'MYSQL_ASSOC') $row = mysql_fetch_array($result, MYSQL_ASSOC); if ($type == 'MYSQL_NUM') $row = mysql_fetch_array($result, MYSQL_NUM); if ($type == 'MYSQL_BOTH') $row = mysql_fetch_array($result, MYSQL_BOTH); if (!$row) return false; return $row; } function insert_sql($table, $sql1, $sql2) { $this->last_query = "Table: " . $table . "Query: " . $sql1 . " | " . $sql2; $row = mysql_query("INSERT INTO `" . $this->prefix . $table . "` (" . $sql1 . ") VALUES (" . $sql2 . ")") or die(mysql_error()); if (!$row) { $this->last_error = mysql_error(); return false; } return true; } function update_sql($table, $sql) { $this->last_query = "Table: " . $table . "Query: " . $sql; $row = mysql_query("UPDATE `" . $this->prefix . $table . "` " . $sql . ""); if (!$row) { $this->last_error = mysql_error(); return false; } return true; } function escape_sql($data) { return mysql_real_escape_string($data); } function print_last_error() { return $this->last_error; } function print_last_query() { return $this->last_query; } } ?> Function being used inside userClass: public function getData ( $userId, $rowName ) { $query = dbClass::sql ( "users", "WHERE `id` = '$userId'" ); if ( mysql_num_rows( $query ) == 1 ) { $row = dbClass::get_row( $query ); } else { return "Error: No rows in query."; } return $row[$rowName]; }
  10. unidox

    Error

    Ok, so I can do two things to my understanding: 1) Use $dbClass->sql instead of dbClass::sql 2) Change $this->last_query to $last_query Am I right?
  11. unidox

    Error

    I have just started picking up PHP again, so my OOP skills are a bit rusty. I keep getting this error: Fatal error: Using $this when not in object context in C:\wamp\www\core\dbClass.php on line 93 That line is: $this->last_query = "Table: " . $table . "Query: " . $sql; I am calling an sql function inside dbClass from userClass: $query = dbClass::sql ( "users", "WHERE `id` = '$userId'" ); Any ideas what I am doing wrong? Thanks
  12. unidox

    Sessions

    Never mind, im a moron haha. I used == instead of =
  13. $sql="REPLACE INTO `findmefollow` ('grpnum', 'strategy', 'grptime', 'grppre', 'grplist', 'annmsg_id', 'postdest', 'dring', 'needsconf', 'remotealert_id', 'toolate_id', 'ringing', 'pre_ring') VALUES ('$_POST[grpnum]','ringall','$_POST[grptime]','$_POST[grppre]',$grplist,'0','$_POST[postdest]','','','0','0','Ring','$_POST[pre_ring]')";
  14. I am making a CMS, and I have a /core/ folder, which contains all my classes for logging in and what not. Now, i am trying to use a class that sets a login session, inside the /admin/ directory. I dont know why, but the sessions are being set. Any ideas? index.php in /admin/: <?php session_start( ); // exit ( $_SESSION['userId'] ); include ("../config.php"); include ("../core/coreClass.php"); include ("../core/dbClass.php"); include ("../core/userClass.php"); define (IN_SCRIPT, true); $coreClass = new coreClass ( ); $dbClass = new dbClass ( $host, $username, $password, $table ); $userClass = new userClass ( ); if ( !$userClass->checkLoggedIn( ) ) { $currentPage = "login"; } elseif ( $coreClass->getGET("page") && file_exists ( "pages/".$coreClass->getGET("page").".php" ) ) { $currentPage = $coreClass->getGET("page"); } else { $currentPage = "home"; } @include ( "processors/".$currentPage.".php" ); include ( "pages/".$currentPage.".php" ); ?> Here is the function that is being called (I know its returning true) This is inside /core/: public function loginUser ( $username, $password ) { $username = coreClass::clean( $username ); $password = coreClass::encrypt( coreClass::clean( $password ) ); $query = dbClass::sql ( "users", "WHERE `username` = '$username' AND `password` = '$password' AND `isActive` = '1'" ); if ( mysql_num_rows( $query ) == 1 ) { $row = dbClass::get_row( $query ); $_SESSION['userId'] == $row['id']; $_SESSION['isLogged'] == 1; $_SESSION['isAdmin'] == $row['isAdmin']; $_SESSION['userLevel'] == $row['accessLevel']; return true; } else { return false; } }
  15. unidox

    Time

    I have a cron that runs every 5 min, that adds information about my server into a db. I have a graph that graphs the last 6 hours (360 min). How do I have the cron remove any expired data from the database? (Greater than 30 min ago.). Any help appreciated. Thanks
×
×
  • 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.