Where can I find example code for phplot? 

by on July 10, 2012

Q: I need help, am new at phplot and need to read blood pressure from a csv file for use in phplot line graph. Since I know very little about this need, sample code would be apprechiated

 
 

What is the Java function that is similar to file_get_contents in PHP? 

by on June 7, 2011

Q: What is Java’s file_get_contents command?

PHP has a way of opening a file for input which creates a handle to the file and locks the file’s access to just that handle and just that instance. PHP also has an instant way called file_get_contents, which does a “virtual file load” and loads the raw data as a string value.

Im developing a Java chat room using a text file which a precoded maximum length slightly below the true potential available.

I ran a simple applet that every 5 seconds, loaded the text of a file into a textfield. It worked fine. I then wanted to use notepad to simulate someone else sending a message. I typed data, clicked save, and notepad said the file access was denied. Considering the sheer speed of Java and the extremely remote probability that I clicked save just as the textfield was being updated, I think i did something wrong. I did make sure the file access was closed immediately after extracting all file contents line by line. Please help is there a more efficient way to do this? If i get the job at the bank, there will be millions of people trying to access one of a few databases at any given time. If 2 clients feeding off the same file every 5 seconds fails, how can I hope to share access globally? This chat program is the masterpeice of mine before I apply for the job. thanks in advance for your help. :-)

 
 

Is there anyway to have PHP scan a folder of images and make a slider? 

by on April 10, 2011

Q: PHP to auto scan folder to create image banner

I wanted to know if their was a way use php to scan a folder get images and create an auto slider with a width of 900px and height of 300px.

It will auto move to the next image in folder and loop back to first image when last image is reached.

 
 

How come my PHP code to create thumbnails works on my local machine but not on production? 

by on April 7, 2011

Q: Code does not work on live site.

My code to auto generate thumbnails from a given folder works fine on localhost but when I test it on live website it does not create the thumbnails.

My code is:

<?php

$orig_directory = “../imagefolder”; //Full image folder
$thumb_directory = “../imagefolder/thumbfolder”; //Thumbnail folder

/* Opening the thumbnail directory and looping through all the thumbs: */
$dir_handle = @opendir($orig_directory); //Open Full image dirrectory
if ($dir_handle > 1){ //Check to make sure the folder opened

$allowed_types=array(‘jpg’,’jpeg’,’gif’,’png’);
$file_parts=array();
$ext=”;
$title=”;
$i=0;

while ($file = @readdir($dir_handle)) {
/* Skipping the system files: */
if($file==’.’ || $file == ‘..’) continue;

$file_parts = explode(‘.’,$file); //This gets the file name of the images
$ext = strtolower(array_pop($file_parts));

/* Using the file name (withouth the extension) as a image title: */
$title = implode(‘.’,$file_parts);
$title = htmlspecialchars($title);

/* If the file extension is allowed: */
if(in_array($ext,$allowed_types)) {

/* If you would like to inpute images into a database, do your mysql query here */

/* The code past here is the code at the start of the tutorial */
/* Outputting each image: */

$nw = 100;
$nh = 100;
$source = “../imagefolder/{$file}”;
$stype = explode(“.”, $source);
$stype = $stype[count($stype)-1];
$dest = “../imagefolder/thumbfolder/{$file}”;

$size = getimagesize($source);
$w = $size[0];
$h = $size[1];

switch($stype) {
case ‘gif’:
$simg = imagecreatefromgif($source);
break;
case ‘jpg’:
$simg = imagecreatefromjpeg($source);
break;
case ‘png’:
$simg = imagecreatefrompng($source);
break;
}

$dimg = imagecreatetruecolor($nw, $nh);
$wm = $w/$nw;
$hm = $h/$nw;
$h_height = $nh/2;
$w_height = $nw/2;

if($w> $h) {
$adjusted_width = $w / $hm;
$half_width = $adjusted_width / 2;
$int_width = $w / $hm;
imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
} else {
imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
}
imagejpeg($dimg,$dest,100);
}
}

/* Closing the directory */
@closedir($dir_handle);

}
?>

<?php //echo “Thumbnails succesfully created “;
header(“Refresh: 0; url=display_thumbs.php”);
?>

Any help is much apprecaited.

Thank you

 
 

Is there any PHP code that will allow users to manage images in a directory? 

by on March 25, 2011

Q: I want to know if anyone has a PHP code to scan a given folder (not subfolder within it) to display images and than give a check box option to delete the image or multi selected images.

 
 

Creating a CSV file with PHP? 

by on February 11, 2010

Q: I need to create a CSV file using PHP, then send that CSV data to SatNav. I am not experienced with PHP, so any direction would be helpful.

 
 

How do I call a PHP script from within another PHP script? 

by on February 2, 2010

Q: Is there are way to call a PHP script within PHP?

I have tired exec() and system() but when running the script from my host (Network solutions) they do not allow command line/cron jobs to run. I have also tried passing a form as well.

All I need is that upon completion of script A then script B (independent of script A) is called by script A.

 
 

Use PHP to display images 

by on January 26, 2010

Q: How can I use PHP to display images on my website that are in a location on the server that the web server does not have access to? Since the web server does not have access to the folder I cannot use a regular HTML IMG tag.

A: There are a few things you need to remember when doing this. The first is that the web server might not have access to the folders/files to display them using a regular URL but the web server does have to have permission to access the folder for the script to get to the files inside of it. If there is a vulnerability in your code or in any other part of the site then you need to understand that not only the images in this “out of the way” directory will be accessible but anything else as well. Read the rest of this entry »

Read Question Here
 
 

How can I use php to display an image file? 

by on January 8, 2010

Q: How can I use PHP to generate complex images from a file? I have a public_html folder on the root of my webhost filesystem. I also created a private_data folder for sensitive information, such as bio profiles. I have the profile picture stored in the private_data/Registration/Profiles/USERNAME/Picture.jpg but because that folder is not accessible on the web, the IMG SRC tag doesn’t work. How can I say something like “img src=blah.php” and the php file actually loads the profile picture? All i understand so far is how to create backgrounds and plaintext into an image. But how do I load a preexisting image file?

Read Answer Here
 
 

Can I use AJAX without using POST? 

by on December 5, 2009

Q: I am just becoming familiar with AJAX and have copy-pasted the coding for sending GET requests to a PHP program. However, a large part of my website contains a function which handles a few large chunks of data. Some of this data can be upwards of 8,000 characters. I am trying to write a page to use AJAX to create articles, upload pictures all without refreshing the page. How can I do this without using POST? And can POST handle a total of 3MB of data (text only, image uploads are handled separately)?