Jump to content

mrhobbz

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by mrhobbz

  1. Good eye, thats what I was looking for. Thanks everyone!
  2. Ehh sort of I was more or less looking to stick them all in a single array say i have four rows in my table all with "pizza" as the common raid column and another four rows with "bagel" as the rad column. I'm trying to stick them into an array such as... pizza ->boss->blah ->boss->blah ->boss->blah ->boss->blah bagel ->boss->blah ->boss->blah ->boss->blah ->boss->blah I'm thinking it may be easier to just use two databases.
  3. I need some help with an array setup, I'm not 100% sure how to do this. To start off, I have a mysql table that has a name and a few other attributes. There will be multiple of the name and different, varrying attributes. Here is the array.. while ($row = mysql_fetch_row($result)){ foreach($row as $key=>$value) { $raid = $row[1]; $boss = $row[2]; $comp = $row[3]; $status = array ( array($raid, $boss, $comp) ); } Basically instead of it creating a seperate array for each row in the table, I want it to merge the array based on the "raid" column. Is there an easy way I can do this or would I be better off using two different databases, one for the "raid" lists and the second for the bosses, querying the "bosses" database and pulling it based on the raid name column?
  4. I got it figured it, removed that pointless expression and the trim and its working fine. Thanks guys.
  5. Its escaped before its stuck into the query string.
  6. Tried that, just using the mysql_real_escape_string and I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'test\', \'098f6bcd4621d373cade4e832627b4f6\', \'test@gmail.com\', \'test\')' at line 1
  7. Good eye, I tried that and i get: Error : MySQL - Database Query [1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usrname usrpass usremail usrhandle VALUES test 098f6bcd4621d373cade4e832627b4f6 ' at line 1
  8. Tried that, still nothing.. I'm passing it through this function: public function query($sql) { $sql = $this->clean_sql($sql); $this->act = @mysql_query($sql, $this->con); if(!$this->act) { $this->err('MySQL', 'Database Query'); } $this->affected_rows = mysql_affected_rows($this->con); } and it shoots the sql statement through this function: public function clean_sql($string) { $string = ereg_replace("[\'\")(;|`,]", "", $string); $string = mysql_real_escape_string(trim($string), $this->con); return $string; }
  9. I'm trying to run this query: $sql = "INSERT INTO i_usr (NULL, usrname, usrpass, usremail, usrhandle) VALUES (NULL, '$username, '$password, '$email', '$handle')"; This is the error it spits out: Error : MySQL - Database Query [1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL usrname usrpass usremail usrhandle VALUES test 098f6bcd4621d373cade4e832627' at line 1 Any ideas?
  10. Thanks for the reply, did some quick skimming on the subjects. This is definitely what I was looking for.
  11. So i've ran into a bit of a wall scalability wise. I've created this simple mysql class based on reading and its working out well so far. However I realize that doing a user management setup is going to require a lot more seperate classes in the end. Does anyone have any advice/suggestions/comments on making this more scalable? <?php // ############################################### // ## mysql.class.php // ############################################### error_reporting(E_ALL); class db { # BEGIN CLASS. /* Class variables */ var $act; // Action container - this will contain our SQL queries. var $con; // Connection container - this will hold our actual connection to our MySQL server. var $affected_rows; // This will hold our affected row count from mysql_affected_rows() command. var $record; // This will hold the retrieved data from our MySQL queries. function db() { # BEGIN CONSTRUCT $this->db_host = 'localhost'; $this->db_user = ''; $this->db_pass = ''; $this->db_base = ''; } # END CONSTRUCT function db_open() { $this->con = @mysql_connect($this->db_host, $this->db_user, $this->db_pass); if (!$this->con) { die($this->err("Connecting to MySQL server.")); } if (!@mysql_select_db($this->db_base, $this->con)) { $this->err('Selecting database'); } // clear variables. $this->db_host = ''; $this->db_user = ''; $this->db_pass = ''; $this->db_base = ''; } function db_close() { // #Close mysql connection. // #This is not really needed unless you're doing a lot of processing on the data and don't want to leave the connection open. // #PHP automatically closes the MySQL connection when the script is finished. if (!@mysql_close($this->con)) { $this->err('MySQL connection.'); } } function escape($string) { return mysql_real_escape_string($string, $this->con); } function db_query($sql) { $sql = $this->escape($sql, $this->con); $this->act = @mysql_query($sql, $this->con); if(!$this->act) { $this->err("Querying database."); } $this->affected_rows = mysql_affected_rows($this->con); } function db_fetchassoc() { // #Fetch associative array. // #no need to add error checking here, if the query before hand fails it will not continue. return mysql_fetch_assoc($this->act); } function db_free() { // #Free mysql resources. mysql_free_result($this->act); } function err($error) { // There is probably a much better way to do this but it works. // We have a header and a footer for the error page, lets load them into the according variables. $fname1 = "inc/err.head"; //Error page header. $file1 = @fopen($fname1, 'r'); $fname2 = "inc/err.foot"; //Error page footer. $file2 = @fopen($fname2,'r'); $head = @fread($file1, filesize($fname1)); $foot = @fread($file2, filesize($fname2)); die( $head . " <img src='img/error_icon.png'></img> <br /> <br /> <hr> <br /> <br /> <b> <font color='#ff2828'>Error : </font></b>" . $error . " <br /> <b> <font color='#5886a7'>[" . mysql_errno() . "]</font> </b>" . mysql_error() . "<br /> <br /> Please contact site administrator" . $foot ); } } # END CLASS! class user_db extends db { #BEGIN USER CLASS var $salt1; //MD5 Beginning salt string. var $salt2; //MD5 Ending salt string. function user_db() { #BEGIN CONSTRUCT $this->salt1 = "mnbcvx1"; //Set beginning salt string. $this->salt2 = "xbrtui"; //Set ending salt string. } #END CONSTRUCT. function salt($string) { //Lets md5 the password and add a salt string. return md5($this->salt1 . $string . $this->salt2); } } #END CLASS!
  12. Didn't even see Thorpes response up there, yeah thats a pretty nice setup as well. Either one of the three should do you well.
  13. I would go with a switch/case like discomat mentioned. Probably the cleanest way to do it.
  14. Else If statement, refer to: http://us.php.net/elseif
  15. there going to be shown on forums thru other web sites sort of like what xbox has for gamertags. IF you're using GD you can still usually stick the script that generates it in an img tag as it outputs the image file.
  16. Whoever this Bill E Bert guy is must have a lot of things going on. Some of the places that you've used flash may be better off without.
×
×
  • 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.