User Profile
Collapse
-
or simply use this <link removed>. -
This is a sample recursive function to display directory contents
...Code:<?php function scandir_recursive($dir) { $items = scandir($dir); foreach($items as $item) { if ($item == '.' || $item == '..') { continue; } $file = $dir . '/' . $item; echo "$file<br />"; if (is_dir($file)) { scandir_recursive($file);Leave a comment:
-
change the line:
to this:Code:$text="<?php include('ClassName.class');$myclass = &new ClassName; echo $myclass->myfunction1(); ?>";
Code:$text="<?php include('ClassName.class');\$myclass = &new ClassName; echo \$myclass->myfunction1(); ?>";Leave a comment:
-
Why not add the path to the filename? suppose the directory is /var/www/upload/content, you can add the path when creating the file.
Code:<?php $filename = '/var/www/upload/content/' . $_POST['title']; $fp = fopen ($filename, "w"); /* ...the rest of your code... */ ?>
Leave a comment:
-
Leave a comment:
-
Get the login username in windows using PHP:
Code:<?php $username = getenv('USERNAME'); ?>Leave a comment:
-
try this:
Code:<?php $date_in = '2008-07-01'; list($year, $month, $day) = explode('-', $date_in); if (checkdate($month, $day, $year)) { echo 'date valid.'; } else { echo 'date invalid'; }Leave a comment:
-
See my tutorials about parsing information from HTML pages:
http://www.nashruddin.com/parsing-ta...html-page.html
http://www.nashruddin.com/page-index...all-pages.html
maybe you'll have any further ideas after reading it....Leave a comment:
-
Things to consider:
1. PHP runs on most operating system, while ASP not.
2. PHP runs faster than Java
3. It's freeLeave a comment:
-
Code:<? $dir = '/some/path/to/mp3'; if (is_dir($dir)) { echo "directory exists"; } else { echo "directory doesn't exist."; /* and create the directory */ mkdir($dir, 0700); } ?>Leave a comment:
-
Using explode() is the most efficient. But here's how to do that with preg_match:
Code:<?php $hostname = 'mg-st-005.xyz.pqr.dyd'; preg_match("/^([^\.]+)\..+$/", $hostname, $matches); echo $matches[1]; /* will print: mg-st-005 */ ?>Leave a comment:
-
Try this:
Code:<?php $path= "/home/wasstech/attachements/".$_FILES['ufile']['name']; if(!empty($_FILES['ufile'])) { if(move_uploaded_file($_FILES['ufile']['tmp_name'], $path)) { echo "Success"; } else { echo "Failed"; } } ?>Leave a comment:
-
Have you add enctype to your form? it looks like this:
Code:<form enctype="multipart/form-data" action="somefile.php" method="post">
Leave a comment:
-
move the code to resize and rename the image in a new function. something like this:
...Code:<?php /* function to resize and rename the uploaded image */ function resize_and_rename($filename) { /* ...some code here...*/ } /* process uploaded image */ if (is_uploaded_file($_FILES['file']['tmp_name'])) { /* check if uploaded image size < 200kb */ if ($_FILES['file']['size']Leave a comment:
-
Or use preg_replace:
Code:$number = preg_replace("/[^0-9\s]/i", "", $number);Leave a comment:
-
Here's the code snippet to rename the uploaded file to ARTIST - TITLE.mp3 and move it to destination folder.
...Code:<?php /* obtain artist name and title from previous form */ $artist = $_POST['artist']; $title = $_POST['title']; /* new name for the uploaded mp3 */ $filename = "$artist - $title.mp3"; /* change to the directory of your mp3s */ $destpath
Leave a comment:
-
You mean you want to debug the variables from your PHP script?
Code:<?php print '<pre>'; print_r($_REQUEST); print '</pre>'; ?>
Leave a comment:
-
Another code for your weird problem:
...Code:<?php $input = 'horse.gallup'; preg_match("/^([\w]+).([\w]+)$/", $input, $matches); $prefix = $matches[1]; $suffix = $matches[2]; for ($i = 0 ; $i < strlen($prefix) ; $i++) { $a = substr($prefix, 0, $i); $b = substr($prefix, $i+1, strlen($prefix)); $text = "$a$b.$suffix";Leave a comment:
-
If you are using Apache, provide .htaccess file like this:
The configuration above will display error.php for HTTP error 401, 403 and 404. And error.php might looks something like this:Code:ErrorDocument 401 error.php?code=401 ErrorDocument 403 error.php?code=403 ErrorDocument 404 error.php?code=404
...Code:<?php switch($_GET['code']) { case '401':Leave a comment:
-
Try this:
call the script with something like image.php?user= myusernam...Code:<?php $text = $_GET['user']; $im = imagecreate(100, 20); $bg = imagecolorallocate($im, 200, 200, 200); $fg = imagecolorallocate($im, 0, 0, 255); imagestring($im, 3, 5, 3, $text, $fg); header("Content-type: image/png"); imagepng($im); ?>Leave a comment:
No activity results to display
Show More
Leave a comment: