{"id":3067,"date":"2014-03-15T03:37:04","date_gmt":"2014-03-15T03:37:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/15\/phpmamprelated-issues-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:47:11","modified_gmt":"2022-08-30T15:47:11","slug":"phpmamprelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/15\/phpmamprelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"php,mampRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/14da0a77145571d61cee03ac6bb0fb35?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nWebnet<br \/>\nphp<br \/>\nI have this code and I need to make this work:if ($handle = opendir(&#8220;images\/&#8221;)) { $i=0;while (false !== ($file = readdir($handle))){if ($file != &#8220;.&#8221; &amp;&amp; $file != &#8220;..&#8221; &amp;&amp; $file != &#8220;Recursive Dir_Renfiles_dirname-filename.php&#8221;) {$filename[$i]=$file;$i++;}}}\/\/print_r($filename);foreach($filename as $filename){$percent = 0.5;\/\/ Content typeheader(&#8216;Content-Type: image\/jpeg&#8217;);\/\/ Get new dimensionslist($width, $height) = getimagesize($filename);$new_width = $width * $percent;$new_height<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/hzsXy.jpg?s=32&amp;g=1\" \/><br \/>\nEmanuil Rusev<br \/>\nphp function<br \/>\nIn CakePHP there is a (quite fundamental) method called find. Most of the time this method would return an array but if you pass count as the first parameter the method would return a different data type &#8211; an integer.The method is allowed to return various data types.Isn&#8217;t that bad?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4b5bda7a482f14167dad12ecf040a8ad?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njela<br \/>\nphp<br \/>\ngiven the following script&lt;?phpini_set(&#8216;display_errors&#8217;,&#8217;On&#8217;); error_reporting(E_ALL);thisisanerror?&gt;I get the expectedNotice: Use of undefined constant error &#8211; assumed &#8216;error&#8217; in \/htdocs\/test.php on line 8but if I add something to the script&lt;?phpini_set(&#8216;display_errors&#8217;,&#8217;On&#8217;); error_reporting(E_ALL);errorfunction test () {echo(&#8216;test&#8217;);}?&gt;I getHTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.Why am<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0d67225ae59a00e7380c72690d64871e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlan Moore<br \/>\nphp regex<br \/>\nI&#8217;m working on a simple project to teach about XSS. I&#8217;m trying to make a regex that will catch &lt;script&gt;alert(&#8216;anything&#8217;)&lt;\/script&gt;;I crafted: &lt;script&gt;alert\\(\\'[\\w!@#$%^&amp;*()-=+]+\\&#8217;\\);&lt;\/script&gt; but when i try to implement it in php I get errors yet when I try it in a regex tool it says it matches my string.Anyone know how to make a regex that works?Thanks<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/22YzC.jpg?s=32&amp;g=1\" \/><br \/>\nMr Biscuit<br \/>\nphp session variables if-statement phpmyadmin<br \/>\nI am trying to create a user login page. Upon successful registration admins are assigned a value of &#8220;A&#8221; in my database and customers a &#8220;C&#8221;. Upon successful login customers will be directed to one page and admins to another. I created three session variables, their userId, userFName and their userType. I want to create an if statement to check the value of userType and have tried everything but I still get the error message &#8220;Parse error: syntax error, unexpected T_ELSE&#8230;on line 74&#8221;.`\/\/create a<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dcce4266f0c054991bf5dbd29794c743?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDominic Rodger<br \/>\nphp variables scope<br \/>\nI have a function with a big hierarchy:function func(){$a= 0; \/\/ Here the variable is 0while(&#8230;){echo $a; \/\/ gives me always 0for(&#8230;){if(&#8230;){if(&#8230;){$num = func3();$a = $num; \/\/ this $a does not corrospond to $a in the beginning}}}} }Does anyone know how I can change the value of $a from the nested scopes?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d5f91983a9d9cfb69981b6108a63b412?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nskaffman<br \/>\nphp exception-handling<br \/>\nWhen throwing a new exception is it best to simply return true if no exception needs to be thrown. Alternatively is it best to return false instead of throwing an exception. Im using php.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8d313c5d85c52a953e498c4f66d59c8a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnoloader<br \/>\nphp sqlsrv<br \/>\nI have experience with mysql databases and have successfully connected to them with a couple dozen projects. Now, I&#8217;m having trouble connecting to a SQL Server 2007. This works: &lt;?php phpinfo(); ?&gt; and the sqlsrv and pdo_sqlsrv sections appear on this page. Here&#8217;s the code that I&#8217;m using to connect: &lt;?php $serverName = &#8220;serverName\\sqlexpress&#8221;; \/\/serverName\\instanceName $connectionInfo = array( &#8220;Database&#8221;=&gt;&#8221;dbName&#8221;, &#8220;UID&#8221;=&gt;&#8221;userName&#8221;, &#8220;PWD&#8221;=&gt;&#8221;password&#8221;); $conn = sqlsrv_connect(<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1e86fc88e6028ac7c04450160a764ae9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChimera<br \/>\nphp function types parameters casting<br \/>\nThis might sound like a silly question to many of you, but it keeps me wondering why PHP does not allow typecasting in its function parameters. Many people use this method to cast into their parameters:private function dummy($id,$string){echo (int)$id.&#8221; &#8220;.(string)$string }Orprivate function dummy($id,$string){$number=(int)$id;$name=(string)$string;echo $number.&#8221; &#8220;.$name; }But looking at many other programming languages, they accept typecasting into their function parameters. But doing this in PH<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/191dbc0ae8b2e1192d867f5e806bbf71?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSumurai8<br \/>\nphp apache .htaccess codeigniter error-handling<br \/>\nMy website has been slowed down a little last couple of days. I&#8217;ve looked into my error log and found lots of these:[Mon Sep 30 00:09:53 2013] [error] [client 66.249.66.205] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use &#8216;LimitInternalRecursion&#8217; to increase the limit if necessary. Use &#8216;LogLevel debug&#8217; to get a backtrace. [Mon Sep 30 00:09:53 2013] [debug] core.c(3120): [client 66.249.66.205] r-&gt;uri = \/home\/mysitecom\/domains\/mysite.com\/public_html\/<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e69e0a928aa0ebd8ae06625a81266582?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nredrom<br \/>\nosx zend-framework mamp<br \/>\ni updated to new version of MAMP 2.1 and I have got a problem with running project based on Zend Framework.If I trying to run script, obtain error Fatal error: syntax error, unexpected T_SL running on MAMPIs any possibility, hot solve it?Thanks for any advice.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/af37a9f9071eafc05b8cf1435914590c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSDP<br \/>\nosx-lion apache mysql mamp<br \/>\nI&#8217;ve been using MAMP for years. Rarely had any issues. I&#8217;m currently running OSX 10.7.4. I just upgraded MAMP to v2.0.5 and bought\/installed MAMP PRO&#8230; but I can&#8217;t get it to work. I can still you MAMP (non-PRO), but I get a 500 error when I try the same local sites with MAMP PRO. Here&#8217;s what I&#8217;ve tried so far&#8230;I&#8217;ve tried with both the MAMP port settings (Apache=8888 MySQL=8889 SSL=88890), and the default web settings (Apache=80 MySQL=3306 SSL=443). Neither works. I&#8217;ve tried each of the follow<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/01153bfb2ff1d19bc453a0b054fd57fd?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJJ56<br \/>\nphp session mamp<br \/>\nI am new to php, and very new to sessions, so I have no idea what I am doing wrong. I followed the tutorial on tizag, and put this code on my site:&lt;?phpsession_start();echo SID . &#8220;&lt;br&gt;&lt;br&gt;&#8221;;if(isset($_SESSION[&#8216;views&#8217;])) {$_SESSION[&#8216;views&#8217;] = $_SESSION[&#8216;views&#8217;] + 1; } else {$_SESSION[&#8216;views&#8217;] = 1;echo &#8220;views = &#8220;. $_SESSION[&#8216;views&#8217;]; }?&gt;The SID changes whenever I refresh, and the number does not count up.Update: Url: http:\/\/121.73.150.105\/PIA\/FIXED BY: Putting session_start() be<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ea273c5748ebd4d990c6bc3cc6ad0935?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLenin<br \/>\nphp netbeans mamp phpdoc<br \/>\nI am trying to get phpdoc working on netbeans but I am getting the following errorPHP Warning: require(PhpDocumentor\/phpDocumentor\/phpdoc.inc): failed to open stream: No such file or directory in \/Applications\/MAMP\/bin\/php\/php5.4.4\/bin\/phpdoc on line 40 PHP Fatal error: require(): Failed opening required &#8216;PhpDocumentor\/phpDocumentor\/phpdoc.inc&#8217; (include_path=&#8217;.:&#8217;) in \/Applications\/MAMP\/bin\/php\/php5.4.4\/bin\/phpdoc on line 40When I run pear config-show in the Terminal I get the following php_dir<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/OT8Vh.jpg?s=32&amp;g=1\" \/><br \/>\naorcsik<br \/>\nphp osx-lion imagemagick mamp homebrew<br \/>\nI installed Imagemagick using Homebrew on Lion, everything is fine except that it doesn&#8217;t work at all when being called from php. Console:$ convert -version Version: ImageMagick 6.7.1-1 2011-07-29 Q16 http:\/\/www.imagemagick.org Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC Features: OpenMP $ which convert \/usr\/local\/bin\/convertPHP:echo exec (&#8216;convert -version&#8217;);orexec(&#8216;convert -version&#8217;, $output);var_dump($output);Produces nothing (or an empty array).exec (&#8216;\/usr\/local\/bin\/convert&#8217;)<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b222843eb023b7d5108cb293983aad60?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBart De Vos<br \/>\nmod-rewrite drupal .htaccess mamp<br \/>\nI&#8217;m having an unusual access problem with Drupal running on a MAMP stack. The Drupal install is working fine, so I know it&#8217;s not a Drupal issue. &#8220;Clean URLs&#8221; are working fine for anything with a single-level url, but nothing with 2+ path levels.For example:example.com\/foo, example.com\/bar, etc. All work perfectly.example.com\/foo\/bar, example.com\/bar\/foo\/bar, etc. Do not work.I get an access denied (not 404) page, served by Drupal, with the login boxes and site name, but no theme applied. (and, y<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ab04bb5fc71a668879849ca9ab1a2f8c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAdam Tuttle<br \/>\nmacosx coldfusion mamp osx-10.6<br \/>\nI&#8217;m using this video tutorial to try and install ColdFusion 9 with MAMP Pro on my Macbook, for development purposes. It works when installing CF8; but with both the 32 bit and 64 bit versions of CF9, I can&#8217;t get it working.I reach the 19 minute mark of the video and add index.cfm to the DirectoryIndex directive, then restart the services in MAMP Pro. Apache fails to stop, requiring a force-quit (not something I did manually, MAMP asked if I wanted it to try to force-quit, I said yes, and it seem<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/09a13f849911db3eb3a6e00b93bdc819?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser2377651<br \/>\nphp android mysql wamp mamp<br \/>\nI&#8217;m trying to do this tutorial (http:\/\/www.androidhive.info\/2012\/05\/how-to-connect-android-with-php-mysql\/) using mamp. I already done this using wamp but unfortunately I have no choice now but to use Mac. I already placed all PHP files under \/Applications\/MAMP\/htdocs\/android_connect\/ and when I tried to run test.php that&#8217;s in \/Applications\/MAMP\/htdocs\/ it worked properly. The app works when i directly copy paste everything but when i tried to change the PHP file url from api.androidhive.info\/an<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/48affea2496e9ce713a0844dc60d9422?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nVegard<br \/>\ngoogle-chrome localhost mamp freeze<br \/>\nI&#8217;ve been working on a localhost project for a while when all of a sudden Chrome either freezes, crashes or takes forever to load the page. I think it all started when I was writing some javascript outputs, but I don&#8217;t know if that&#8217;s related.The wierd thing is that other projects in localhost works as normal in Chrome. It seems to be just some php files that runs extremely slow in this particular project. I&#8217;m running localhost via MAMP, if that&#8217;s any help.The project works just fine in Safari an<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0d9002e0f658dc20286ad400ff58c539?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAnk<br \/>\nmysql cron backup mamp timemachine<br \/>\nnot sure its a stack overflow questionI have a Mac and am hosting a Apache MySQL server on it using MAMP Pro. If I back up my data on the time machine, is MySQL database also backed up or do I have to create mysqldump and backup up as a cron job? In case of a crash do I do a normal restore in case it can be backed up on time machine.Thanks<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Webnet php I have this code and I need to make this work:if ($handle = opendir(&#8220;images\/&#8221;)) { $i=0;while (false !== ($file = readdir($handle))){if ($file != &#8220;.&#8221; &amp;&amp; $file != &#8220;..&#8221; &amp;&amp; $file != &#8220;Recursive Dir_Renfiles_dirname-filename.php&#8221;) {$filename[$i]=$file;$i++;}}}\/\/print_r($filename);foreach($filename as $filename){$percent = 0.5;\/\/ Content typeheader(&#8216;Content-Type: image\/jpeg&#8217;);\/\/ Get new dimensionslist($width, $height) = getimagesize($filename);$new_width = $width * $percent;$new_height Emanuil Rusev [&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,8],"tags":[],"class_list":["post-3067","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-zend-framework"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3067","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=3067"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3067\/revisions"}],"predecessor-version":[{"id":8909,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3067\/revisions\/8909"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}