![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
keldorn
Members-
Posts
340 -
Joined
-
Last visited
Never
Everything posted by keldorn
-
Exactly.
-
You can use .htaccess and check for referrers. If the referrer is from Google images, then use mod_rewrite. You will need something in the image to identify it, like an ID in the image name. So you could have ID_randomString.jpg So say 3222_8due938d.jpg, using mod_rewrite you can grab the 3222 with regex, then point that to a php file like image.php?image_id=3222 Inside image.php you will have to 301 redirect them with ID to an album with the 3222 ID.
-
They probably shove alot of the data in Memcached too.
-
Ok, I'll just take that route, serialization doesn't sound like my cup of tea anyways. Thanks. I probably likely wont have scaling issues the size of Youtube, but it is always good to design your application right from the start with scaling in mind.
-
So you think that would scale? I wonder how say Youtube handles it, imagine they million of users, with each say 100 favorites, that would be potntional hundreds of millions of row in a table. I dont see it working. Maby on a small scale.
-
I'm building an application, I wanted to add the ability of the user to favorite stuff. What is good way to go about storing the favorite data? I'm thinking here, making a table for each user is not a good idea, I really trying think how sites like Youtube do this without scaling issues, would you save all their favorites in an Array and serialize it in the 1 row along with their username? Then when you need just unserislize and it and iterate over it, Is that how places like Youtube does it? or create 1 big table dump for all favorite of everybody and just have it sorted from userid=>user recursion? Like id + user_id + favorite_id THen just do SELECT favorite_id FROM favorites where user_id=$userid
-
Put print_r($varItem) right near the heart of the problem to see if it an array, if it you see something like Array( [1]=> "", [2]=> ""; etc. , Then yes you have an array probably being inserted into the query, which wont work. <?php // Some pre tags so it displays as plain text in the browser. echo "<pre>"; print_r($varItem); echo "</pre>"; // exit , and see the output of print_r exit; Database::ExecuteQuery("INSERT INTO `rating` (`item_name`, `rating`, `ip_address`, `date_rated`) VALUES ('{$varItem}', {$varRating}, '{$ipAddress}', NOW())", "InsertRating");
-
how do I know if the content is really gziped or not
keldorn replied to Cardale's topic in PHP Coding Help
You can also use Yslow (Nice Firefox ext. for web developing too) , you can look in the components section and will tell you if its gzipped by comparing the gziped size to uncompressed size, or the gzip size will be just empty to indicate its not gziped. -
Your query looks correct. I was looking over the first code and noticed $averageStars = Rating::CalculateAverageRating($varItem); The problem might be the Rating method. Maby its not expecting a Single Quote ? You never know with OOP there could be some thing that stop the query from excuting inside the Rating::CalculateAverageRating method when it finds what it thinks is garbage input (The single quote and slash) Edit: Also are you sure that $varitem is not an array? Inserting it as $varItem wont work if it is, its will just insert "Array" in the database. You need access its indexes in the query like .... VALUES ('{$varItem['name']}', .... By the looks of the var_dump, I would say maby it is, put print_r($varItem); to see if its an array. (But then again somewhere else in the code the variable could be reassigned. Lke $varItem = $varItem['name'] )
-
Your saying you can't get the data to insert so do the usual, 1. Put or die(mysql_error()) on your query, examine if there is an sql error. 2. check that your table names are correct. Mysql sometimes just returns false and not an error. 3. Check that your WHERE statment is correct. 4. Check the table row is varchar with at least a length of least 20, and utf8_general_ci and is not Int 5. Is $varItem actually an Array?, if it is you have to do this, $varitem['index'] 5. Check that your mysql is plugged in. Giovannis\'s store is perfectly fine to put into database, there is nothing wrong with it, the problem likely is in your query.
-
No they won't Your right they both function the same, the slash disappears once its put into the database. Rather to correct myself, if you have magic_quotes_gpc on, and put addslashes(), the it will be double-slashed, and the slashes will appear in the database. @OP, This is the proper why to detect magic quote <?php if (function_exists('get_magic_quotes_gpc')) { $varItem = stripslashes($varItem); } $varItem = mysql_real_escape_string($varItem); Also put use var_dump($varItem); to see that it the expected input, echo doesn't show the whole story, and also put or die(mysql_error()); on your query to see if there is an error. Remember garbage in garbage out. Check your inputs.
-
When you use mysql_real_escape_string() the slashes disappear once the data is safely inside the database. Thats the difference between mysql_real_escape_string() and addslashes() . With addslashes() , the slashes will still be on the string when its in the DB.
-
>>> I think this is bug, I didn't quote myself.
-
I didnt own a PC until Windows xp was out. Well I did have prior experience using computers when Windows 95 was out, but they weren't my mine, Just friends and the ones at my school. In 1998 computers had like 256MB ram, and that was considered top of the line. The internet was a collection of a pages thrown together with blinking .gifs and construction signs. I remember in 2001 when I hit Grade 9 , there was this computer science class, I can't remember the name of it, but someone was building a website on one of the computers, I think it was there that I realized that was something I wanted to do,but unfortunately that wasnt part of the class, again I can't even remember what the class was teaching, but it wasn't anything like that. It wasn't until a fews years later in 2005 I got my own computer, then I installed apache, mysql, phpmyadmin , and started casually messing around with it and learning. It took till 2009 before I could actually program anything PHP.
-
Mhz: 2 RAM: 0.256 VS Mhz: 9,320 RAM: 4,000,000 That is hilarious, I guess if you wanted to mutlply it, if 2 Mhz computer in 1975 cost $1,987.0, then one with 9,320 should cost $1,987.08 x 2/9,320 = $9, 259, 420 xD
-
I installed Memcached from memcached.org and installed this tutorial. http://blog.ajohnstone.com/archives/installing-memcached/ So I do this, <?php $memcache = new Memcache; $memecache->connect("localhost",11211); $foo = $memcache->("obj:foo"); if(!$foo){ $foo = mysql_query("SELECT * FROM `foo` LIMIT 0,10"); $foo = mysql_fetch_assoc($foo); if(is_array($foo){ $memcache->add("obj:foo",$foo,false,600); } } That set it too expire in 600 seconds or 10 minutes. So I updated Foo, and waited for 10 minutes and refreshed the page, but still showing the old memcache object. I even waited a few more minutes, still showing the old object. I had to delete that key and reset it to show the update. What the heck is wrong with the expire? It doens't work like that? I'm also getting confused because of this, http://www.php.net/manual/en/book.memcache.php http://www.php.net/manual/en/book.memcached.php
-
Yeah a prombt would come and say , what browser would like to use? With a modal of browsers shown. Of course they will probably call up their tech knowing friends and go "Hey what browser do I pick?, help!".
-
This is what happens when you give the control of everything mechanical to the digital part of the device. xD If the digital device is flawed your &($&*($. For example a while back, I bought a house fan with a digital on/off and also settings for the speed, the damn thing broke after 5 minutes, and it wouldn't come on no matter how much I pressed those digital buttons, the power was not getting to the fan. never had that trouble with a mechanical on/off switch fan. How about those digital radios? I remember once I couldnt get a music CD out of the player becuase it had a digital eject button that pushes it out, and it was fried, I had to smash to the thing apart to get the CD out! I like digital though, but it has its drawbacks. But Digital cars? I'm seriously considering the scenarios here in the next 10 years or more, when these electronic parts in these hundreds of thousands of cars start frying. Electronic components dont last long.
-
Rising of oceans now apparently caused by god's tears..
keldorn replied to 448191's topic in Miscellaneous
CSRF link? -
Failed Deletes, Inserts, updates and database anomalies
keldorn posted a topic in Application Design
I tried searching for this, but could not find anything. What if your application is very Acid, and say what happens if there is failed Query that could cause some serious database anomalies, what would be best to deal with that? Take for example you have 2 categories, Foo and Bar, Foo and bar ave each 1 Widget, in the table for the categories it lists how many widgets it has, so it would be Foo (1) bar (1) Now say you do a SQL query and move the widget from bar to Foo, so in the database you update the widgets table and point its category to foo, then you update categories to decrement bar by 1 and increase Foo by 1, but here what happens is that query fails becuase at the point their some network outage on that remote mysql server, or mysql is too busy and accidental drops the UPdate or it get lost or something etc., and to make matters worse you have and die() on that query, so now Both widets are listed in Foo , and the whole script process dies and it didn't update the categories, now you have an anomaly silently away in your DB! foo (1) bar (1) But it should be Foo (2) Bar (0) What would could be done to prevent this? Would you catch the failed queries and re-run them? or roll back the queries? -
I cant see the internet thrive the way it is using proprietary databases, Its the main reason why most use PHP,linux, mysql. Its free, having to pay licenses and all that is too cost prohibitive since it creates barriers to entry for the smaller players, ultimately it would hurt the economy, so there is good reason why these mergers can be blocked by court orders.
-
So I've been using out Netbeans again for the last week, I'm starting to like it. haha I'm such a hypocrit. But no actually I installed an HD 4670 with 1 GB GDDR2 Vram just recently becuase the price of these cards has come down alot in the past 8 months, and Java virtual machine must like it becuase it working ALOT faster now,except for the lag part when you start when the virtual machine complies the code. But hey I guess if that is what it takes... The price you pay for writing apps in interpreted languages is that you'll need some good hardware to use it.
-
Do you mean storing an associative array with the servers in a config, like <?php $servers = ('1'=>array('ip_address'=>'67.159.0.1', 'host'=>'static1.example.com' ), '2'=>array('ip_address'=>'67.159.0.2', 'host'=>'static2.example.com' ), ) Then when you upload an image, you pick one from there randomly, then connect to it via FTP, then upload the image, then store in the database the full imageurl. (static2.example.com/uploads/). Okay so you'll know where they are stored and if you ever need to scale it more and those servers are full, you can just remove them from the server array, and add new fresh servers. I probably might never have this problem, but I am thinking ahead about scalability. I even realize that FTP probably wont scale, I think the fastest way might be too send a POST to a server at some obsucure port with the image data and then have some multi-threaded non-blocking application there written in C wiating on that port to take that and write it fast to disk or shove it in memory waiting to be written to disk, of course there would be no auth, so you would have to firewall the server, kinda like how if your using memcached. On port 80 you might having something like Varnish or Nginx serving the images.
-
I remember using Apache,mysql, php on my windows computers some years back. It was slow as hell on windows. Even on localhost, I would refresh the page and will sometimes lag for 3 seconds. Definitely something there on windows that is slowing it down.
-
License to sell software online with access to modify by paid users
keldorn replied to zohab's topic in Website Critique
I think you have to includes the sourcecode with it, if its based on GPL. It does say in the GNU GPL Licence: