Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

Leppy's Achievements


Newbie (1/5)



  1. Well said, I understand now. Thank you!
  2. Hello, I've been doing some research on this forum and I haven't really found anything that answer my question which is, what is the difference between static and non-static methods and variables? The main reason why I am asking is because I like to use the syntax class::method() or class::$variable because it makes more sense and also because when I use the class within function I do not have to declare GLOBAL $my_class. Another reason why I'm asking is, in order to be able to use the methods or variable I call using class::method() or class::$variable, I need to specify the "static" keyword all the time otherwise I get a PHP error #2048 Non-static method which I find very annoying. That being said, what is the difference between static and non-static? When should "static" be used and why? Any help is appreciated, Thank you. Leppy-
  3. How do I do that? Could you link me to a php reference, I could read more about it.
  4. That might work, although I'm not sure how I will be able to decode the string to find "blah blah blah" if the base64 is strtolower. Any idea?
  5. Hello, I use the following code to encode my URLs on my site: urlencode(base64_encode("blah blah blah")); Which results in someting like this: YmxhaCBibGFoIGJsYWg And then I put a link on my site using this code <a href="/script/YmxhaCBibGFoIGJsYWg/">Click me</a> It works fine. Although to make a long story short, I added, inside the script who handles the URL, a debug function to let me know if the code "YmxhaCBibGFoIGJsYWg" exist in the DB or not. If it doesn't it sends me an e-mail with the user's browser and requested URL. I've been getting emails lately and I'm clueless about what might be the problem. It is mostly the following User Agent: Java/1.6.0 and sometimes: Microsoft URL Control - 6.00.8862 The requested URL by both browsers is: /script/ymxhacbibgfoigjsywg/ It looks like they are not taking the capital letters in the URL. It is a bug in the browser or it is a bug in my script/URL ? If it is a bug in the browser, is there a way I could use only non-capitalized letters with base64 or an alternative of base64? Any would be appreciated! Thank you, Leppy-
  6. I've been trying to search on google and here but I haven't found anything on the subject. What I want to know is, which one of these is a better practice. 1. Having 1 row for hour so 24 rows per day 2. Having 1 row per day but 24 fields in the table Which one would be the best to go for, assuming my table will grow very large in the future. Thank you for any inputs.
  7. That's what I was thinking... Is it common practice to do something like that? Maybe my table structure could be better... Since I create a row for every hour there is an action, would it be better if I create 1 row per day but have 24+ field (24 hours) in the table ? Would I gain in performance? I would surely have a lot less rows in the table for starter...
  8. The data I am inserting is not big at all it only a set of number that I put in the database, would it be slow because the table is large?
  9. MySQL version: 5.0.45 My problem: My update/insert queries are slow which makes large amount of data to be insert taking forever (~5000 row = 50+ seconds). My table (10 million rows): `id` int(11) unsigned NOT NULL auto_increment, `gid` int(11) unsigned NOT NULL default '0', `tid` int(11) unsigned NOT NULL default '0', `d` date NOT NULL default '0000-00-00', `h` time NOT NULL default '00:00:00', `rh` smallint(11) unsigned NOT NULL default '0', `uh` smallint(11) unsigned NOT NULL default '0', `rc` smallint(11) unsigned NOT NULL default '0', `uc` smallint(11) unsigned NOT NULL default '0', `rj` smallint(11) unsigned NOT NULL default '0', `uj` smallint(11) unsigned NOT NULL default '0', PRIMARY KEY (`id`), KEY `d` (`d`), KEY `gid` (`gid`), KEY `tid` (`tid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10477780 ; I've tried to delete the indexes but it is making it worst, I've tested without any index, with 1 index and with 2 indexes and here are the results: With only primary key: 2.2648708820343 seconds With primary + 1 index (d): 0.03847599029541 seconds with primary + 2 index (gid): 0.02488112449646 seconds (with the 3rd index the time is almost the same as 2.) Shouldn't be suppose to be the opposite? I recently move my database to a standalone server so no other process than mysql should be using the CPU and the hard drive. I did not really optimize my mysql configuration because I do not know what I need to change in order to optimize the performance. [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock set-variable = max_connections=500 set-variable = thread_cache_size=150 set-variable = table_cache=250 set-variable = query_cache_size=40M set-variable = read_rnd_buffer_size=6M set-variable = key_buffer_size=512M set-variable = tmp_table_size=256M set-variable = wait_timeout=60 #log=/mt/mysql_query.log old-passwords #log-bin #server-id=1 #log-warnings log-slow-queries=/var/log/mysql/slow.log [mysql.server] user=mysql #basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid I'm using the following code (in PHP) in order to insert my data inside mysql, fairly simple query... $query=mysql_query("UPDATE tableA SET rh=rh+1 WHERE gid={$gid} AND tid={$tid} AND d='{$d}' AND h='{$h}:00:00'"); $query =mysql_affected_rows(); if(!$_query){ mysql_query("INSERT INTO tableA (`gid`,`tid`,`d`,`h`,`rh`,`uh`) VALUES ({$gid},{$tid},'{$d}','{$h}:00:00',1,0)"); } I tried running my script on the same server as the mysql server but it did not change anything. Any suggestion would be appreciated! Thank you! Leppy-
  10. Ahhh that's what I was looking for, thank you!!
  11. Hello, I would like to know if there is any functions I should use on every data entered by a user before making my SQL query to make it secure so the user cannot try to mess with the database? I usually do addslashes sometimes but is there a function that I could use on every variable that I will use in my SQL query that would make it secure in everyway? Basically what I'm asking is what is the best secure way of making mySQL queries. Thank you!
  12. Try this to see if there is any error in your query: $userdata = mysql_fetch_assoc(mysql_query("SELECT * FROM user_info WHERE username = '$username'")); if (isset($_POST['submit'])){ if(!mysql_query("UPDATE user_info SET username = '$_POST[username]', email = '$_POST[email]', project = '$_POST[project]', active = '$_POST[status]', admin rights = '$_POST[rights]' WHERE username = '$_GET[user]'")){ echo 'something is wrong: '.mysql_error(); } else { echo "Your Information has been successfully updated."; }} But what I suspect is there is no affected rows so there is something not right with your query. Are you sure the row you are trying to update exist?
  13. Sounds like you do not have register global on, try to use $_REQUEST['p'] or $_GET['p'].
  14. Hello, I have a PHP script that uses MySQL for almost all its features. Although, in a few days, I will need to move the PHP script to another server but the MySQL database will remains on its own server. So I will have 2 servers, 1 with the script and 1 with the MySQL database. Now, I could easily create a new mysql user and allowing only the IP address of the server where the script is but is it safe and/or a good practice? And most importantly is it fast? I've used this method in the past and honestly it was slowing down my scripts a inch and I need it to be running as fast as it can be. I've thought about mysql replication but my DB is over 2 GB and there are alot of entries made every 10 minutes and I'd like to safe as much bandwidth as I can. The information I need from the database on my php script is in about 2 table and is less than 1 MB so replicating 2GB+ would not such a good idea, space and bandwidth wise, correct me if I'm wrong though. I've also thought about creating the needed table on a database on the PHP server, but if I need to update it, I'd like it to be updated on the 2 servers without me having to code another script. Perhaps someone here have a suggestion or a thought on what I should do... Any ideas would be greatly appreciated. Regards
  • 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.