honkmaster
Members-
Posts
49 -
Joined
-
Last visited
Everything posted by honkmaster
-
Thank you very much for your help, I now understand where I was going wrong, Cheers Chris
-
first part of script this cam up INCOMING ARRAYS: $_POST: Array ( [company] => test [nouploads] => 1 [submit] => Submit ) $_FILES: Array ( ) Then when I submit the file I this INCOMING ARRAYS: $_POST: Array ( [MAX_FILE_SIZE] => 2000000 ) $_FILES: Array ( [userfile] => Array ( [name] => Array ( [0] => test 2.JPG ) [type] => Array ( [0] => image/jpeg ) [tmp_name] => Array ( [0] => /Applications/XAMPP/xamppfiles/temp/phprNKfX2 ) [error] => Array ( [0] => 0 ) => Array ( [0] => 409173 ) ) )
-
I added and got the following Notice: Undefined variable: undefined_variable in /Applications/XAMPP/xamppfiles/htdocs/workflow/upload3.php on line 13
-
No error when I test at all, it seems to be the Variable $target is not working at the end of line starting $upload_dir. I have put the echo in to see what is working?
-
Ok, I have put on error reporting and fixed errors, I have also added echo to see what is happing. All works apart from the file does not end up in the "company" directory it ends up in the "image" directory with the "company" folders. This is what is echoing back to start with "uploads/image/CompanyName/" Once the Directory is created it should put the uploaded files in the "CompanyName" directory. What i get echoed back is "uploads/image//" the "CompanyName" is missing Very confused, any help would be great Cheers Chris <?php error_reporting(-1); //posted from form if(isset($_POST['company'])) $target = "$_POST[company]"; if(isset($_POST['nouploads'])) $nouploads = "$_POST[nouploads]"; { global $target, $nouploads, $dir; } echo $target; echo "<br />"; //make a dir with the same name as company //does not matter if it already exists if (!file_exists ( "uploads/image/$target/" )) { mkdir("uploads/image/$target/", 0777, true); } //directory to upload to $upload_dir = "uploads/image/$target/"; echo $upload_dir; echo "<br />"; //number of files to upload passed by form $num_uploads = "$nouploads"; //maximum filesize allowed in bytes $max_file_size = 2000000; //the maximum filesize from php.ini $ini_max = str_replace('M', '', ini_get('upload_max_filesize')); $upload_max = $ini_max * 2000000; //a message for users $msg = 'Please select files for uploading'; //an array to hold messages $messages = array(); //check if a file has been submitted if(isset($_FILES['userfile']['tmp_name'])) { //loop through the array of files for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++) { //check if there is a file in the array if(!is_uploaded_file($_FILES['userfile']['tmp_name'][$i])) { $messages[] = 'No file uploaded'; } //check if the file is less then the max php.ini size elseif($_FILES['userfile']['size'][$i] > $upload_max) { $messages[] = "File size exceeds $upload_max php.ini limit"; } //check the file is less than the maximum file size elseif($_FILES['userfile']['size'][$i] > $max_file_size) { $messages[] = "File size exceeds $max_file_size limit"; } else { //copy the file to the specified dir if(@copy($_FILES['userfile']['tmp_name'][$i],$upload_dir.'/'.$_FILES['userfile']['name'][$i])) { //give praise and thanks to the php gods $messages[] = $_FILES['userfile']['name'][$i].' uploaded'; } else { //an error message $messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed'; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Multiple File Upload</title> </head> <body> <h3><?php echo $msg; ?></h3> <p> <?php if(sizeof($messages) != 0) { foreach($messages as $err) { echo $err.'<br />'; } } ?> </p> <form enctype="multipart/form-data" action="upload3.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" /> <?php $num = 0; while($num < $num_uploads) { echo '<div><input name="userfile[]" type="file" /></div>'; $num++; } ?> <input type="submit" value="Upload" /> </form> </body> </html>
-
I have tried with double quotes as //directory to upload to $upload_dir= "uploads/image/$company"; I'm just trying to understand why it isn't working??
-
thanks, the app is not WAN facing just used internaly on our LAN to help store content by company name. I just don't under stand why the files don't end up in the right place. If I replace the $company bit with a company name i.e "uploads/image/$company" to "uploads/image/companyname" it works?? Cheers Chris
-
Hi, I have an issue with the following code. I want to upload files to a directory named by a form i.e "uploads/image/$company" the company name is posted from the form. The issue is the files don't end up where I want? i.e they land "uploads/Image" along side the directory ANy help would be great, its driving me mad!! <?php //testing post echo "$_POST[nouploads]"; echo "<br />"; echo "$_POST[company]"; //posted from form $nouploads = "$_POST[nouploads]"; $company = "$_POST[company]"; //make a dir with the same name as company //does not matter if it already exists if (!file_exists ( "uploads/image/$company" )) { mkdir("uploads/image/$company", 0777, true); } error_reporting(E_ALL); //directory to upload to $upload_dir= 'uploads/image/$company'; //number of files to upload passed by form $num_uploads = "$nouploads"; //maximum filesize allowed in bytes $max_file_size = 2000000; //the maximum filesize from php.ini $ini_max = str_replace('M', '', ini_get('upload_max_filesize')); $upload_max = $ini_max * 2000000; //a message for users $msg = 'Please select files for uploading'; //an array to hold messages $messages = array(); //check if a file has been submitted if(isset($_FILES['userfile']['tmp_name'])) { //loop through the array of files for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++) { //check if there is a file in the array if(!is_uploaded_file($_FILES['userfile']['tmp_name'][$i])) { $messages[] = 'No file uploaded'; } //check if the file is less then the max php.ini size elseif($_FILES['userfile']['size'][$i] > $upload_max) { $messages[] = "File size exceeds $upload_max php.ini limit"; } //check the file is less than the maximum file size elseif($_FILES['userfile']['size'][$i] > $max_file_size) { $messages[] = "File size exceeds $max_file_size limit"; } else { //copy the file to the specified dir if(@copy($_FILES['userfile']['tmp_name'][$i],$upload_dir.'/'.$_FILES['userfile']['name'][$i])) { //give praise and thanks to the php gods $messages[] = $_FILES['userfile']['name'][$i].' uploaded'; } else { //an error message $messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed'; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Multiple File Upload</title> </head> <body> <h3><?php echo $msg; ?></h3> <p> <?php if(sizeof($messages) != 0) { foreach($messages as $err) { echo $err.'<br />'; } } ?> </p> <form enctype="multipart/form-data" action="upload3.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" /> <?php $num = 0; while($num < $num_uploads) { echo '<div><input name="userfile[]" type="file" /></div>'; $num++; } ?> <input type="submit" value="Upload" /> </form> </body> </html>
-
Hi I have a column in my database which is called "lastupdated" it stores a unix date and time stamp '1331299541' Fri, 09 Mar 2012 13:25:41 GMT. I want to run a query to retrieve any activity that happens that day i.e the day we are currently in. $query = "SELECT * FROM contacts WHERE lastupdated = '1331299541'"; As you can see i'm quite new to this so looking to be pointed in the right direction. I know its to do with formatting the date stamp? Cheers Chris
-
Hi, i'm trying to change the status column in a table I have based on the last date updated column older than 10 days. This is the query I have so far <?php date_default_timezone_set('Europe/London'); $now = time(); mysql_connect(localhost,$dbusername,$dbpassword); @mysql_select_db($db_name) or die( "Unable to select database"); $query="UPDATE contacts SET status = 'New Prospect' WHERE status = 'Allocated' AND lastupdated < now('d,-10')"; $result=mysql_query($query); mysql_close(); ?>
-
What I'm trying to do rather badly I feel is echo back just the count part and not the name of the printer. So I'm getting this Canon 1 and I want 1 I want to return the result into some think like this $key1 Cheers Chris
-
Hi, can anyone help me with this. I have a column in my table call "machine", I want to count the number of time each appears and return the results into an array In the example below the number of times each printer appears in the column is returned to the array ____________ machine ____________ fb7500-1 fb7500-2 turbojet turbojet xl1500-1 xl1500-2 canon roland When I run the following I get the names as well as the values and I just want the values?? Result like this Canon 1 FB7500-1 1 Roland 1 TurboJet 2 Vutek QS3200 1 XL1500-1 1 <?php mysql_connect("localhost","XX","XX"); @mysql_select_db("schedule") or die( "Unable to select database"); date_default_timezone_set('Europe/London'); $query = "SELECT machine, COUNT(machine) FROM maindata GROUP BY machine"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ $array = array( 'key1' => $row[0], 'key2' => $row[1],'key3' => $row[2],'key4' => $row[3], 'key5' => $row[4],'key6' => $row[5],'key7' => $row[6]); extract($array); echo "$key1<br>$key2<br>$key3<br>$key4<br>$key5<br>$key6<br>$key7"; } ?>
-
Hi I'm using a the following google Pie Cart from here http://code.google.com/apis/ajax/playground/#pie_chart I would like to use php to COUNT printers listed in a column called machine and return result so I can echo it into google code Example of Column below would return a count of one for each except for the TurboJet which would return two. I would then like to echo the results to the google Javascript for printer 1 to 6. _______ machine ________ FB7500-1 TurboJet XL1500-1 Roland Canon TurboJet Can anyone help? Cheers Chris <?php mysql_connect("localhost","chris","Cr2baxKUHWGxr6nn"); @mysql_select_db("schedule") or die( "Unable to select database"); date_default_timezone_set('Europe/London'); $query = "SELECT machine, COUNT(machine) FROM maindata GROUP BY machine"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are is ". $row['COUNT(machine)'] ." ". $row['machine'] ." items."; echo "<br />"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title> Google Visualization API Sample </title> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['corechart']}); </script> <script type="text/javascript"> function drawVisualization() { // Create and populate the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'Task'); data.addColumn('number', 'Hours per Day'); data.addRows(5); data.setValue(0, 0, 'Printer 1'); data.setValue(0, 1, 11); data.setValue(1, 0, 'Printer 2'); data.setValue(1, 1, 2); data.setValue(2, 0, 'Printer 4'); data.setValue(2, 1, 2); data.setValue(3, 0, 'Printer 5'); data.setValue(3, 1, 2); data.setValue(4, 0, 'Printer 6'); data.setValue(4, 1, 7); // Create and draw the visualization. new google.visualization.PieChart(document.getElementById('visualization')). draw(data, {title:"Current Work in Progress"}); } google.setOnLoadCallback(drawVisualization); </script> </head> <body style="font-family: Arial;border: 0 none;"> <div id="visualization" style="width: 600px; height: 400px;"></div> </body> </html>
-
Hi I'm trying to paginate results from a query, I have tried to use the Pear Pager file as its quite configurable. I'm stuck at present and keep getting the following error messages (fig1a.png) Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/foscosn1/public_html/cbs/christest.php on line 24 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/foscosn1/public_html/cbs/christest.php on line 25 Can anyone point me in the right direction. Also I'm getting a blank line at the top of results in (fig1a) and I can't workout why?? Cheers Chris <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <link href="main.css" rel="stylesheet" type="text/css" /> <link href="allother.css" rel="stylesheet" type="text/css" /> </head> <body> <?php /* Include the Pear::Pager file */ require_once ('Pager/Pager.php'); $con = mysql_connect("localhost","XXXX","XXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("XXXX", $con); /* First we need to get the total rows in the table */ $result=mysql_query("SELECT COUNT(*) AS total FROM main_data", $connection); $row = mysql_fetch_array($result); /* Total number of rows in the logs table */ $totalItems = $row['total']; /* Set some options for the Pager */ $pager_options = array( 'mode' => 'Sliding', // Sliding or Jumping mode. See below. 'perPage' => 10, // Total rows to show per page 'delta' => 4, // See below 'totalItems' => $totalItems, ); /* Initialize the Pager class with the above options */ $pager = Pager::factory($pager_options); /* Display the links */ echo $pager->links; /* The following code will retreive the result using the pager options */ /* The function below will get the page offsets to be used with the database query. For e.g if we are on the third page then the $from variable will have the value of '21' (we are showing 10 items per page, remember) and the $to variable will have the value of '30'. */ list($from, $to) = $pager->getOffsetByPageId(); /* The MySQL 'LIMIT' clause index starts from '0', so decrease the $from by 1 */ $from = $from - 1; /* The number of rows to get per query */ $perPage = $pager_options['perPage']; $result = mysql_query("SELECT orderNumber, dateReceived, status FROM main_data ORDER BY dateReceived LIMIT $from , $perPage"); echo '<table border=0 cellpadding=6 >'; echo '<tr class=tableHead>'; echo '<td>ORDER NUMBER</td><td>DATE RECEIVED</td><td>STATUS</td>'; echo '</tr>'; while($row = mysql_fetch_array($result)) { echo '<tr class=tableBody>'; echo '<td>' . $row['orderNumber'] . '</td>'; echo '<td>' . $row['dateReceived'] . '</td>'; echo '<td>' . $row['status'] . '</td>'; echo '</tr>'; } mysql_close($con); ?> </body> </html> [attachment deleted by admin]
-
Guru Thanks for help, Cheers Chris Yes, but it depends what you are trying to achieve. If you are wanting to allow the user to not select a value, then set that option to an empty value. However, if you want to force the user to select one of the values, then still set that option to an empty value and then do a validation on the server to ensure the value of that field !-''
-
Guru, that's great worked at treat, more importantly I can see how you achieved the goal which is going to help me learn, Thank you. One thing I forgot to say, the STATUS column in the man_data table is populated from a html dropdown list (see code example) if a status is not selected then "Please Select" which is the instruction shows in the database. (fig 3) <select name="status" id="status"> <option selected="selected">Please Select Status</option> <option value="In Progress">In Progress</option> <option value="Order Received">Order Received</option> <option value="Waiting for Artwork">Waiting for Artwork</option> <option value="Waiting for Approval">Waiting for Approval</option> <option value="Complete">Complete</option> <option value="On Hold">On Hold</option> </select> Is there away of stopping this? Cheers Chris [attachment deleted by admin]
-
Guru, thanks that makes sense to me know. I have tried the code below on my database and I just get a black screen without any error message. Thanks for help , Cheers Chris <?php // Make a MySQL Connection mysql_connect("localhost", "XXXX", "XXXX") or die(mysql_error()); mysql_select_db("XXXX") or die(mysql_error()); $counts = array( 'In Progress' => 0, 'Order Received' => 0, 'Waiting for Artwork' => 0, 'Waiting for Approval' => 0, 'Complete' => 0, 'On Hold' => 0 ); $query = "SELECT status, COUNT(Status) as count FROM main_data GROUP BY status"; $result = mysql_query($query) or die(mysql_error()); while($record = mysql_fetch_assoc($result)) { $counts[$record['status']] = $record['count']; } $output = "<table>\n"; $output .= " <tr><th colspan=\"4\">CURRENT STATUS REPORT</th></tr>\n"; $record = 0; foreach ($counts as $status => $value) { $record++; if ($record%2==1) { $output .= " <tr>\n"; } $output .= " <td>{$status}</td>\n"; $output .= " <td>{$value}</td>\n"; if ($record%2==0) { $output .= " </tr>\n"; } } $output = "</table>\n"; echo $output; ?>
-
Hi All status controls in the same table, the code I have returns as lines which works but I want to return the status as in fig 2 in a table format. Cheers Chris
-
Hi, I'm quite new to PHP so sorry if this is basic. I have a MySQL database with a table in called status. There is 6 status possibilities STATUS In Progress Order Received Waiting for Artwork Waiting for Approval Complete On Hold So far this is what I have got, it counts the status and groups them and presents back as screen shot attached (Fig1) This is great but what I want it to do is present results in a table format like screen shot attached (Fig2). Where there is no result I would like a "0" Can anyone point me in the right direction <?php $username="XXXX"; $password="XXXX"; $database="XXXX"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT status, COUNT(Status) FROM main_data GROUP BY status"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are ". $row['COUNT(Status)'] ." Records at ". $row['status'] ." Status."; echo "<br />"; } ?> [attachment deleted by admin]