{"id":6730,"date":"2014-04-22T12:41:59","date_gmt":"2014-04-22T12:41:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/22\/phpredisphpredisrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-04-22T12:41:59","modified_gmt":"2014-04-22T12:41:59","slug":"phpredisphpredisrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/22\/phpredisphpredisrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"php,redis,phpredisRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5733ae447942dd8d7b7fed04715d2c59?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nzuc0001<br \/>\nphp ajax<br \/>\nI am calling for a function inside of a class on my website. It works on the majority of pages from what I&#8217;ve noticed, however when it tries to do the same thing on AJAX pages (pages that are only accessed through AJAX requests), it seems to error.function formatUsername($id,$link = true,$styles = true, $class = &#8221;){global $users;return $users-&gt;formatUsername($id,$link,$styles,$class); }is where it is erroring (the return $users-&gt;) bit. (global.php)The actual formatUsername code is: (class.us<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/C5oYx.jpg?s=32&amp;g=1\" \/><br \/>\nSerge Roussak<br \/>\nphp memory-leaks large-files<br \/>\nI get the subj. when I try to make backup of my database in a text file.function backup_tables($backup_filename, $tables = &#8216;*&#8217;) {$conf = new JConfig();$dbhost = $conf-&gt;host;$dbuser = $conf-&gt;user;$dbpassword = $conf-&gt;password;$dbname = $conf-&gt;db;$link = mysql_connect($dbhost, $dbuser, $dbpassword);mysql_select_db($dbname, $link) or die(mysql_error());$return = &#8220;drop database if exists `$dbname`;\\n\\ncreate database `$dbname`;\\n\\nuse `$dbname`;\\n\\n&#8221;;$return .= &#8220;\/*!40101 SET @OLD_CHARACT<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1dbafe0b813afe397131e17d7c5cacbe?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nYour Common Sense<br \/>\nphp mysql<br \/>\n&lt;?phpini_set(&#8216;max_execution_time&#8217;, 300); \/\/300 seconds = 5 minutes$par1=&#8217;0&#8242;;$db -&gt; autocommit(FALSE); \/\/ start transaction$stmtInv = $db-&gt;prepare(&#8220;SELECT invoice,date,route,customer FROM test WHERE type = ? GROUP BY invoice&#8221;);$par1=&#8221;Sales Receipt&#8221;;$stmtInv -&gt; bind_param(&#8216;s&#8217;,$par1);$stmtInv -&gt; execute();$stmtInv -&gt; bind_result($invoice,$date,$route,$customer);\/\/ loop 9,000 recordswhile($stmtInv -&gt; fetch()){ \/\/update statements}$stmtInv -&gt; free_result();$stmt = $db-&gt;prep<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d477c242cc2f45f1d891546c08c54ff8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTomFirth<br \/>\nphp mysqli fatal-error<br \/>\nI&#8217;ve searched a lot of basically the same questions on SO which haven&#8217;t seemed to help. Been a while since i&#8217;ve touched php so i&#8217;m guessing there&#8217;s a simple solution but really can&#8217;t figure it out.config.php: (included into admin.php)$mysqli = new mysqli($mHost, $mUser, $mPass, $db);admin.php:$sqlQuery = &#8220;INSERT INTO `category` (`id`, `name`) VALUES (&#8221;, &#8216;$_POST[name]&#8217;)&#8221;; $result = $mysqli-&gt;query($sqlQuery);var_dump($result) returns: NULLand gives error: Fatal error: Call to a member function qu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0b75597d276b0328122dd12e8c3b981c?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nAnagh<br \/>\nphp rss simplepie<br \/>\nI started using simplepie for RSS and I encountered this error in the very first stage itself.Fatal error: Class &#8216;SimplePie_Misc&#8217; not found in C:\\Program Files\\EasyPHP-12.1\\www\\simplepie\\library\\SimplePie.php on line 59EDIT The main folder is called &#8216;simplepie&#8217; The sub folders and files arebuild cache compatibilty_test css idn includes library(has SimplePie.php and a folder called SimplePie) tests index.phpTHIS IS THE CODE&lt;?php \/\/Load simplepie library require_once &#8216;includes\/autoloader.php<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4786299716d2ec443be20984705ba8b9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRobert K<br \/>\nphp windows curl<br \/>\nI need to make work CURL IN WAMPRunning cmd.exe, I am able to use curlcurl -L http:\/\/www.google.comBut when using my website locally (using WAMP, PHP Version 5.3.13) even with enabling extension for curl.I get an error:Fatal error: Call to undefined function curl_init()My PC is a Windows 7 64 bit..Any ideas on how to solve it?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/MGhY2.png?s=32&amp;g=1\" \/><br \/>\nhakre<br \/>\nphp simplexml<br \/>\nI am experiencing a very odd error. I am writing a function to validate XML based on element names, in this case passed in as an array. First, I normalize the input to a SimpleXMLElement object; in this case I am passing in a DOMDocument, and I tested it, it is converting correctly to SimpleXMLElement.What confuses me is that calling getName() will throw the following:PHP Fatal error: Call to a member function getName() on a non-objectBut using exit($xml-&gt;getName()) (or echo) will return the<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/dRgVP.png?s=32&amp;g=1\" \/><br \/>\nYi Jiang<br \/>\nphp html<br \/>\nFatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 13965430 bytes)PHPInfo shows that I have a memory_limit of 128M, so I&#8217;m confused as to why the error says I only have 64M&#8230; Is it possible for phpinfo to report incorrectly? Or for PHP to use two separate php.inis?[UPDATE] The error was being caused by an ini_set call in one of the primary php files that a co-worker of mine added without my knowledge. Thanks for your help guys.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/988288735cdcfe612676c2389e34a5c7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nIMUXIxD<br \/>\nphp search-engine web-crawler<br \/>\nThere are two pieces to this code: One that adds documents to an index to be searched, which works fine, and a crawl() function that is a web-crawler that gets the contents of a page, which also works fine.But, I need to add a document from inside the crawl() function.When I move the code that adds a document inside the crawl() function, I get a Fatal Error: Fatal Error: call to member function addDocument() on a non-object.I am wondering how I can access the member function addDocument() from i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7fb6b9bc012cd839a99ba778c722c5a7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nxdazz<br \/>\nphp pdo prepared-statement<br \/>\nI was getting this Fatal error at the bottom of the page and didn&#8217;t see it right away. The error was pointing to a variable, the $sql, an SQL string, which is supposed to be an SQL string. The code was &#8220;$s = $pdo-&gt;prepare($sql);&#8221;. It seemed to work right, accessing the database and retrieving the correct information. I had used this code before earlier on another page creating a new PDO connection. Finally, after reading one of the comments on this error which I can&#8217;t find again, I decid<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f8dc8fabdbce2f177e3f5029775a0587?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSiva<br \/>\nredis<br \/>\nI am trying to start the redis-server that was installed in windows PC as deamonize service. I configured the redis.conf file to accept the pidfile and logfile path as follows:pidfile D:\\HMS Build\\redis\\bin\\redis.pid &#8230;. logfile D:\\HMS Build\\logs\\redis.logWhile i was trying to start the server, i am getting the following error message.*** FATAL CONFIG FILE ERROR *** Reading the configuration file, at line 52 &gt;&gt;&gt; &#8216;logfile D:\\HMS Build\\logs\\redis.log&#8217; Can&#8217;t open the log file: Invalid arg<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5d75f8af878f069a3b5939894c2e57ab?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nposeid<br \/>\nchef redis chef-solo<br \/>\nI am trying to install Redis with Chef. I would think, it&#8217;s easy, since I only want to have the default configuration.So, I add to a Berksfile:site :opscodecookbook &#8216;apt&#8217; cookbook &#8216;node&#8217; cookbook &#8216;rvm&#8217;, :git =&gt; &#8220;https:\/\/github.com\/fnichol\/chef-rvm&#8221; cookbook &#8216;runit&#8217; cookbook &#8216;redis&#8217;Then, I run: vagrant provisionBut I get this:2013-12-11T21:18:23+00:00] DEBUG: chef_gem[rvm] is already installed &#8211; nothing to do [2013-12-11T21:18:23+00:00] DEBUG: Loading Recipe rvm::vagrant via include_recipe [2013-<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4263a524ac9ab8d629a454cd61cae2c0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNarek<br \/>\nredis phpredis<br \/>\nUPDATE &#8211; SOLUTION FOR MENeed to install redis-server, in Ubuntu by command: sudo apt-get install redis-serverI installed phpredis, an can see in phpinfo():Redis Version 2.2.3After calling class constructor:$redis = new Redis(); $redis-&gt;connect(&#8216;127.0.0.1&#8217;, 6379, 2.5);everything is ok.print_r($redis);returns Redis Object ( [socket] =&gt; Resource id #21 ). But when I want to call any other method, for example:$redis-&gt;info();I got error:Fatal error: Uncaught exception &#8216;RedisException&#8217; with<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ec9707ead27c44bb6c8bc12e65bda4a6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDavid Villa<br \/>\nruby-on-rails ruby redis hiredis<br \/>\nI am trying to install recommendify gem.This gem try to compile a native bin called recommendify to be faster than ruby\u00b4s parser.First i tried to install like other common gem:gem install recommendifyand this is the error:? ~ gem install recommendify Building native extensions. This could take a while&#8230; ERROR: Error installing recommendify: ERROR: Failed to build gem native extension.\/Users\/villa\/.rbenv\/versions\/1.9.3-p448\/bin\/ruby extconf.rbmake mkdir -p ..\/bin gcc -Wall recommendify.c -lh<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f156b2dd1a05b3c6397913fbd6c39bad?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nilupper<br \/>\nsql redis relational in-memory<br \/>\nI have a simpleton question on Redis. If the key to it&#8217;s performance is that it&#8217;s in-memory, whey can&#8217;t that be done on a regular SQL db?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/wo21B.jpg?s=32&amp;g=1\" \/><br \/>\nremudada<br \/>\npython websocket redis uwsgi asyncsocket<br \/>\nHi I have a simple websocket server which is pushing messages to clients, the code is as followsuwsgi.websocket_handshake(env[&#8216;HTTP_SEC_WEBSOCKET_KEY&#8217;], env.get(&#8216;HTTP_ORIGIN&#8217;, &#8221;))print(&#8220;websockets&#8230;&#8221;)r = redis.StrictRedis(host=&#8217;localhost&#8217;, port=6379, db=0)channel = r.pubsub()channel.subscribe(&#8216;backchannel&#8217;)websocket_fd = uwsgi.connection_fd()redis_fd = channel.connection._sock.fileno()while True:uwsgi.wait_fd_read(websocket_fd, 3)uwsgi.wait_fd_read(redis_fd)uwsgi.suspend()fd = uwsgi.ready_fd()<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/db869d4e8c636d15bd18678f6ced444b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nShafik Yaghmour<br \/>\nc redis undefined-behavior<br \/>\nI had a problem in reading redis source code, can anyone tell me what is the use of the last statement in the _redisAssert function in debug.c:*((char*)-1) = &#8216;x&#8217;;`,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/UfwuE.jpg?s=32&amp;g=1\" \/><br \/>\nigorpavlov<br \/>\nnode.js redis node-redis<br \/>\nI am using NodeJS + Express + Redis on RedisOnGo + node_redis as a client. I expect a lot of concurrency, so trying to test WATCH. This example won&#8217;t contain Express, just necessary stuff.var redis = require(&#8220;redis&#8221;) var rc = redis.createClient(config.redis.port, config.redis.host)rc.auth(config.redis.hash, function(err) {if (err) {throw err} })rc.on(&#8216;ready&#8217;, function () {rc.set(&#8220;inc&#8221;,0)for(var i=1;i&lt;=10;i++){rc.watch(&#8220;inc&#8221;)rc.get(&#8220;inc&#8221;,function(err,data){var multi = rc.multi()data++ \/\/ I do<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3b0513d720af96f4496f4b869fe9579a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDidier Spezia<br \/>\nredis<br \/>\nConsider following example:#include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;errno.h&gt; #include &lt;hiredis\/hiredis.h&gt;int main(int argc, char **argv) {redisContext *redis;redisReply *reply;redis = redisConnect(&#8220;127.0.0.1&#8221;, 6379);if(redis-&gt;err) {fprintf(stderr, &#8220;Connection error: %s\\n&#8221;, redis-&gt;errstr);exit(EXIT_FAILURE);}reply = redisCommand(redis, &#8220;SET %s %s&#8221;, &#8220;foo&#8221;, &#8220;bar&#8221;);printf(&#8220;SET %s %s: %s\\n&#8221;, &#8220;foo&#8221;, &#8220;bar&#8221;, reply-&gt;str);freeReplyObject(reply);reply = redisCommand<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/db81ad9316f4bfe29eaadaef54978d0b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nScott<br \/>\nc# redis servicestack<br \/>\nWe&#8217;re using ServiceStack RedisClient for caching. Lately we had some network latency between Redis and our web server. We use PooledRedisClientManager. We noticed the following behavior when we send a command (specifically Get):There&#8217;s some latency in the network We get a SocketIO exception: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4263a524ac9ab8d629a454cd61cae2c0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNarek<br \/>\nredis phpredis<br \/>\nUPDATE &#8211; SOLUTION FOR MENeed to install redis-server, in Ubuntu by command: sudo apt-get install redis-serverI installed phpredis, an can see in phpinfo():Redis Version 2.2.3After calling class constructor:$redis = new Redis(); $redis-&gt;connect(&#8216;127.0.0.1&#8217;, 6379, 2.5);everything is ok.print_r($redis);returns Redis Object ( [socket] =&gt; Resource id #21 ). But when I want to call any other method, for example:$redis-&gt;info();I got error:Fatal error: Uncaught exception &#8216;RedisException&#8217; with<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f4a091d03eb138e977a4fabad7ec1c7e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nStephen Sarcsam Kamenar<br \/>\nphp redis phpredis<br \/>\n&#8220;PHP Fatal error: Uncaught exception &#8216;RedisException&#8217; with message &#8216;read error on connection'&#8221;The driver here is phpredis$redis-&gt;blpop(&#8216;a&#8217;, 0);This always times out after ~1 minute. My redis.conf says timeout 0 and $redis-&gt;getOption(Redis::OPT_READ_TIMEOUT) returns double(0)If I do this it has never timed out $redis-&gt;setOption(Redis::OPT_READ_TIMEOUT, -1);Why do I need -1? Redis documentation says timeout 0 in redis.conf should never time me out.&#8221;By default recent versions of Redis don<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>zuc0001 php ajax I am calling for a function inside of a class on my website. It works on the majority of pages from what I&#8217;ve noticed, however when it tries to do the same thing on AJAX pages (pages that are only accessed through AJAX requests), it seems to error.function formatUsername($id,$link = true,$styles = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6730","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6730"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6730\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}