php,mampRelated issues-Collection of common programming errors


  • Webnet
    php
    I have this code and I need to make this work:if ($handle = opendir(“images/”)) { $i=0;while (false !== ($file = readdir($handle))){if ($file != “.” && $file != “..” && $file != “Recursive Dir_Renfiles_dirname-filename.php”) {$filename[$i]=$file;$i++;}}}//print_r($filename);foreach($filename as $filename){$percent = 0.5;// Content typeheader(‘Content-Type: image/jpeg’);// Get new dimensionslist($width, $height) = getimagesize($filename);$new_width = $width * $percent;$new_height

  • Emanuil Rusev
    php function
    In 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 – an integer.The method is allowed to return various data types.Isn’t that bad?

  • jela
    php
    given the following script<?phpini_set(‘display_errors’,’On’); error_reporting(E_ALL);thisisanerror?>I get the expectedNotice: Use of undefined constant error – assumed ‘error’ in /htdocs/test.php on line 8but if I add something to the script<?phpini_set(‘display_errors’,’On’); error_reporting(E_ALL);errorfunction test () {echo(‘test’);}?>I getHTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.Why am

  • Alan Moore
    php regex
    I’m working on a simple project to teach about XSS. I’m trying to make a regex that will catch <script>alert(‘anything’)</script>;I crafted: <script>alert\(\'[\w!@#$%^&*()-=+]+\’\);</script> 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

  • Mr Biscuit
    php session variables if-statement phpmyadmin
    I am trying to create a user login page. Upon successful registration admins are assigned a value of “A” in my database and customers a “C”. 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 “Parse error: syntax error, unexpected T_ELSE…on line 74”.`//create a

  • Dominic Rodger
    php variables scope
    I have a function with a big hierarchy:function func(){$a= 0; // Here the variable is 0while(…){echo $a; // gives me always 0for(…){if(…){if(…){$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?

  • skaffman
    php exception-handling
    When 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.

  • noloader
    php sqlsrv
    I have experience with mysql databases and have successfully connected to them with a couple dozen projects. Now, I’m having trouble connecting to a SQL Server 2007. This works: <?php phpinfo(); ?> and the sqlsrv and pdo_sqlsrv sections appear on this page. Here’s the code that I’m using to connect: <?php $serverName = “serverName\sqlexpress”; //serverName\instanceName $connectionInfo = array( “Database”=>”dbName”, “UID”=>”userName”, “PWD”=>”password”); $conn = sqlsrv_connect(

  • Chimera
    php function types parameters casting
    This 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.” “.(string)$string }Orprivate function dummy($id,$string){$number=(int)$id;$name=(string)$string;echo $number.” “.$name; }But looking at many other programming languages, they accept typecasting into their function parameters. But doing this in PH

  • Sumurai8
    php apache .htaccess codeigniter error-handling
    My website has been slowed down a little last couple of days. I’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 ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace. [Mon Sep 30 00:09:53 2013] [debug] core.c(3120): [client 66.249.66.205] r->uri = /home/mysitecom/domains/mysite.com/public_html/

  • redrom
    osx zend-framework mamp
    i 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.

  • SDP
    osx-lion apache mysql mamp
    I’ve been using MAMP for years. Rarely had any issues. I’m currently running OSX 10.7.4. I just upgraded MAMP to v2.0.5 and bought/installed MAMP PRO… but I can’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’s what I’ve tried so far…I’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’ve tried each of the follow

  • JJ56
    php session mamp
    I 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:<?phpsession_start();echo SID . “<br><br>”;if(isset($_SESSION[‘views’])) {$_SESSION[‘views’] = $_SESSION[‘views’] + 1; } else {$_SESSION[‘views’] = 1;echo “views = “. $_SESSION[‘views’]; }?>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

  • Lenin
    php netbeans mamp phpdoc
    I 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 ‘PhpDocumentor/phpDocumentor/phpdoc.inc’ (include_path=’.:’) 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

  • aorcsik
    php osx-lion imagemagick mamp homebrew
    I installed Imagemagick using Homebrew on Lion, everything is fine except that it doesn’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 (‘convert -version’);orexec(‘convert -version’, $output);var_dump($output);Produces nothing (or an empty array).exec (‘/usr/local/bin/convert’)

  • Bart De Vos
    mod-rewrite drupal .htaccess mamp
    I’m having an unusual access problem with Drupal running on a MAMP stack. The Drupal install is working fine, so I know it’s not a Drupal issue. “Clean URLs” 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

  • Adam Tuttle
    macosx coldfusion mamp osx-10.6
    I’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’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

  • user2377651
    php android mysql wamp mamp
    I’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’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

  • Vegard
    google-chrome localhost mamp freeze
    I’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’t know if that’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’m running localhost via MAMP, if that’s any help.The project works just fine in Safari an

  • Ank
    mysql cron backup mamp timemachine
    not 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

Web site is in building