php-general Digest 1 May 2010 18:54:30 -0000 Issue 6722 Topics (messages 304802 through 304819):
SharePoint 304802 by: Robbert van Andel 304803 by: Robbert van Andel 304809 by: Tommy Pham Re: How to Force IE to download text file? 304804 by: Ali Asghar Toraby Parizy Object or such for building a directory tree? 304805 by: Michelle Konzack 304810 by: tedd Re: Any One See where this is going wrong? 304806 by: Jim Lucas 304807 by: tedd 304808 by: Gary 304811 by: tedd 304813 by: Gary 304814 by: Gary 304817 by: Adam Richardson Re: multi dimensional array question 304812 by: Programming Guides 304819 by: Nick Balestra A stupid question about classes 304815 by: Andre Polykanine 304816 by: Nilesh Govindarajan Project TIME calculated, in PHP 304818 by: justino garcia Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net ----------------------------------------------------------------------
--- Begin Message ---I've been trying to connect to our SharePoint server's webservices with PHP. I downloaded the nusoap library and have been trying to make a connection using sample code from various websites. I keep getting the following error: <h1>You are not authorized to view this page</h1> You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept. <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2> My code looks like this: require_once('/usr/share/php/nusoap/nusoap.php'); /* Your username and password, separated by a colon Domain may be optional, depending on your setup */ $auth = "username:password"; /* Location of the Lists.asmx file If the list is in a subsite, the subsite must be in the path */ $wsdl = "http://domain.com/depts/is/private/_vti_bin/Lists.asmx?WSDL"; /* GUID of the list */ $guid = "Shared Documents"; /* Setup NuSOAP Sharepoint requires NTLM Authorization You need a fairly recent version of CURL installed for this */ try { $client = new nusoap_client($wsdl,true); $client->setCredentials("","","ntlm"); $client->setUseCurl(true); $client->useHTTPPersistentConnection(); $client->setCurlOption(CURLOPT_USERPWD, $auth); //$client->soap_defencoding = 'UTF-8'; $xml = ' <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>' . $guid . '</listName> <viewName>All Documents</viewName> <query> <xsd:schema>schema</xsd:schema>xml</query> <viewFields> <xsd:schema>schema</xsd:schema>xml</viewFields> <rowLimit>string</rowLimit> <queryOptions> <xsd:schema>schema</xsd:schema>xml</queryOptions> <webID>string</webID> </GetListItems> </soap:Body> </soap:Envelope> '; $result = $client->call("GetListItems",$xml); if(isset($fault)) { echo "<p>Error: " . $fault . "</p>\n"; } echo "<pre>\$result = " . htmlspecialchars(print_r($result,true)) . "</pre>\n"; } catch(Exception $e) { echo "<p>" . $e->getMessage() . "</p>\n"; } Our SharePoint server uses integrated authentication. I've tried several permutations of the username, including just the username, domain\username and usern...@domain. All are returning the same error. My guess is that PHP is sending the username/password combination in a way that SharePoint doesn't like. Has anyone been able to connect to SharePoint's web services and if so, how? Thanks
--- End Message ---
--- Begin Message ---I've been trying to connect to our SharePoint server's webservices with PHP. I downloaded the nusoap library and have been trying to make a connection using sample code from various websites. I keep getting the following error: <h1>You are not authorized to view this page</h1> You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept. <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2> My code looks like this: require_once('/usr/share/php/nusoap/nusoap.php'); /* Your username and password, separated by a colon Domain may be optional, depending on your setup */ $auth = "username:password"; /* Location of the Lists.asmx file If the list is in a subsite, the subsite must be in the path */ $wsdl = "http://domain.com/depts/is/private/_vti_bin/Lists.asmx?WSDL"; /* GUID of the list */ $guid = "Shared Documents"; /* Setup NuSOAP Sharepoint requires NTLM Authorization You need a fairly recent version of CURL installed for this */ try { $client = new nusoap_client($wsdl,true); $client->setCredentials("","","ntlm"); $client->setUseCurl(true); $client->useHTTPPersistentConnection(); $client->setCurlOption(CURLOPT_USERPWD, $auth); //$client->soap_defencoding = 'UTF-8'; $xml = ' <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>' . $guid . '</listName> <viewName>All Documents</viewName> <query> <xsd:schema>schema</xsd:schema>xml</query> <viewFields> <xsd:schema>schema</xsd:schema>xml</viewFields> <rowLimit>string</rowLimit> <queryOptions> <xsd:schema>schema</xsd:schema>xml</queryOptions> <webID>string</webID> </GetListItems> </soap:Body> </soap:Envelope> '; $result = $client->call("GetListItems",$xml); if(isset($fault)) { echo "<p>Error: " . $fault . "</p>\n"; } echo "<pre>\$result = " . htmlspecialchars(print_r($result,true)) . "</pre>\n"; } catch(Exception $e) { echo "<p>" . $e->getMessage() . "</p>\n"; } Our SharePoint server uses integrated authentication. I've tried several permutations of the username, including just the username, domain\username and usern...@domain. All are returning the same error. My guess is that PHP is sending the username/password combination in a way that SharePoint doesn't like. Has anyone been able to connect to SharePoint's web services and if so, how? Thanks
--- End Message ---
--- Begin Message ---> -----Original Message----- > From: Robbert van Andel [mailto:swimmer1...@gmail.com] > Sent: Friday, April 30, 2010 11:58 PM > To: PHP list - not junk > Subject: [PHP] SharePoint > > I've been trying to connect to our SharePoint server's webservices with PHP. > I downloaded the nusoap library and have been trying to make a connection > using sample code from various websites. I keep getting the following error: > > <h1>You are not authorized to view this page</h1> You do not have > permission to view this directory or page using the credentials that you > supplied because your Web browser is sending a WWW-Authenticate header > field that the Web server is not configured to accept. > <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server > configuration.<br>Internet Information Services (IIS)</h2> > ... > > Our SharePoint server uses integrated authentication. I've tried several > permutations of the username, including just the username, > domain\username and usern...@domain. All are returning the same error. > My guess is that PHP is sending the username/password combination in a > way that SharePoint doesn't like. > > Has anyone been able to connect to SharePoint's web services and if so, > how? > > Thanks > Hi, Is the SharePoint web app security configured as NTLM or Kerberos? I presume the authentication type is Windows? Have you tried http://user:passw...@domain.com/full/path/of/url?qryParam=value? Regards, Tommy
--- End Message ---
--- Begin Message ---attachment is correct syntax and solves the problem. Thanks On Fri, Apr 30, 2010 at 9:44 PM, Andre Polykanine <an...@oire.org> wrote: > Hello Ali, > > It's attachment, not attachement. Maybe here's the reason? Just a > thought. > -- > With best regards from Ukraine, > Andre > Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ > jabber.org > Yahoo! messenger: andre.polykanine; ICQ: 191749952 > Twitter: m_elensule > > ----- Original message ----- > From: Ali Asghar Toraby Parizy <aliasghar.tor...@gmail.com> > To: php-gene...@lists.php.net <php-gene...@lists.php.net> > Date: Friday, April 30, 2010, 7:19:38 PM > Subject: [PHP] How to Force IE to download text file? > > I have written this code to export data to a text file and asks user > to save generated file. It works with Firefox perfectly, but IE shows > content of file instead of prompting the download window. > How can I force IE to show the download dialog? > > <?php > Header("Content-disposition: attachement; filename=data.txt"); > Header("Content-type: text/plain"); > echo $some_data; > ?> > > -- > Ali Asghar Torabi > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Ali Asghar Torabi
--- End Message ---
--- Begin Message ---Hello *, before I reinvent the wheel, I ask here, if someone know an "object" or "function" which build from an array of directories (filesystem or IMAP) a directory tree which can be opened and close? I have the need to do this for a "local and remote filesystem" and a "courier-imap tree". Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator -- ##################### Debian GNU/Linux Consultant ###################### Development of Intranet and Embedded Systems with Debian GNU/Linux itsyst...@tdnet France itsyst...@tdnet UG (haftungsbeschränkt) Gesch. Michelle Konzack Gesch. Michelle Konzack Apt. 917 (homeoffice) 50, rue de Soultz Kinzigstraße 17 67100 Strasbourg/France 77694 Kehl/Germany Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil Tel: +33-9-52705884 fix <http://www.itsystems.tamay-dogan.net/> <http://www.flexray4linux.org/> <http://www.debian.tamay-dogan.net/> <http://www.can4linux.org/> Jabber linux4miche...@jabber.ccc.de ICQ #328449886 Linux-User #280138 with the Linux Counter, http://counter.li.org/signature.pgp
Description: Digital signature
--- End Message ---
--- Begin Message ---At 1:59 PM +0200 5/1/10, Michelle Konzack wrote:Hello *, before I reinvent the wheel, I ask here, if someone know an "object" or "function" which build from an array of directories (filesystem or IMAP) a directory tree which can be opened and close? I have the need to do this for a "local and remote filesystem" and a "courier-imap tree". Thanks, Greetings and nice Day/Evening Michelle Konzack SystemadministratorHi Michelle:You have one of the longest signature files I've seen in a while. If at all possible, please trim it for the archives.Now on to your problem. You want to take a multidimensional array that contains the names of directories and names of the files contained therein and show them in a file tree where you can open and close the nodes of the tree to show contents -- is that correct?It's pretty simple to populate an array in PHP to contain directories and files. To do this via PHP can produce something like this:http://php1.net/b/file-browserI'm not happy with the result because it doesn't show a file tree complete with clickable nodes.While I am sure it's possible to do this in PHP, I was thinking that javascript might provide a better functional solution (i.e., client-side with less trips to the server). Namely have PHP create the array and then have javascript show it.This is what I found: http://labs.abeautifulsite.net/projects/js/jquery/fileTree/demo/ It works for me. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---Gary wrote:I have this duplicate code on another site and it works fine. The image is uploaded to the images folder, the information is not submitted to the database. I get the errorSome Error Occured While Inserting RecordsThis is only on a local machine so I have not yet included and safegaurds like stripslashes or my_real_escape_string.Thanks for your help Gary <?php if (isset($_POST['submit'])) { $manufacturer=($_POST['manufacturer']); $type=($_POST['type']); $model=($_POST['model']); $caliber=($_POST['caliber']); $condition=($_POST['condition']); $price=($_POST['price']); $description=($_POST['description']); $image_file_name=($_POST['image_file_name']); $image_file=($_FILES['image_file']); $available=($_POST['available']); $image_file = $_FILES['image_file']['name']; $image_type = $_FILES['image_file']['type']; $image_size = $_FILES['image_file']['size']; include ('includes/connect_local.inc.php');Is the following line suppose to be working with a constant or the variable that you defined/extracted just above here?if(image_size >3000000) { class ImgResizer { private $originalFile = 'image_file'; public function __construct($originalFile = 'image_file') { $this -> originalFile = $originalFile; } public function resize($newWidth, $targetFile) { if (empty($newWidth) || empty($targetFile)) { return false; } $src = imagecreatefromjpeg($this -> originalFile); list($width, $height) = getimagesize($this -> originalFile); $newHeight = ($height / $width) * $newWidth; $tmp = imagecreatetruecolor($newWidth, $newHeight);imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);if (file_exists($targetFile)) { unlink($targetFile); }imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 - 100 for output image quality with 100 being the most luxurious} } } if (!empty($type) && !empty($image_file)) {if (($image_type == 'image/gif') || ($image_type == 'image/jpeg') || ($image_type == 'image/pjpeg') || ($image_type == 'image/png') &&By the use of a variable below, I'm guessing it was suppose to be a variable.($image_size <3000000)) { if ($_FILES['image_file']['error'] == 0) { // Move the file to the target upload folder $target = 'images/' . $image_file;if (move_uploaded_file($_FILES['image_file']['tmp_name'], $target)){$batchconnection;$sqlStatements = "INSERT INTO guns( id,manufacturer, type, model, caliber, condition, price, description, image_file_name,submitted ,available) VALUES ('','$manufacturer', '$type', '$model', '$caliber', '$condition', '$price', '$description','$image_file_name', ' ', '$available');INSERT INTO images (id, image_file) VALUES('','$image_file')"; $sqlResult = $batchconnection->multi_query($sqlStatements); if($sqlResult == true) { echo "Successfully Inserted Records"; } else { echo "Some Error Occured While Inserting Records"; } } } } } mysqli_close($batchconnection); }?>__________ Information from ESET Smart Security, version of virus signature database 5076 (20100430) __________ The message was checked by ESET Smart Security. http://www.eset.com-- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
--- End Message ---
--- Begin Message ---At 1:45 AM +0100 5/1/10, Ashley Sheridan wrote:On Fri, 2010-04-30 at 20:43 -0400, Gary wrote:I have this duplicate code on another site and it works fine. The image is uploaded to the images folder, the information is not submitted to the database. I get the error Some Error Occured While Inserting Records This is only on a local machine so I have not yet included and safegaurds like stripslashes or my_real_escape_string. Thanks for your help Gary <?php if (isset($_POST['submit'])) { $manufacturer=($_POST['manufacturer']); $type=($_POST['type']); $model=($_POST['model']); $caliber=($_POST['caliber']); $condition=($_POST['condition']); $price=($_POST['price']);> $description=($_POST['description']); --snip-Is it possible that this server doesn't like batch queries? Try splitting them out into individual queries and seeing if that helps. If that doesn't do the trick, print out the SQL query string to see if it's what you expect. It might be working fine on the other server, but I've seen enough strange things happen before to know that sometimes 'poo' happens. Thanks, Ash http://www.ashleysheridan.co.ukAsh: 'poo'? Wow, you're becoming quite the Hemingway :-)If the OP does clean his $_POST before putting the results in his database, his database will look like 'poo' if the wrong person comes along.Also, the OP's code reads: ($image_type == 'image/pjpeg') || ($image_type == 'image/png') && That should be: ($image_type == 'image/jpeg') || ($image_type == 'image/png') &&Regardless of IF the code runs OK somewhere else it won't if it's dealing with a jpeg or even a jpg image.Plus, the logic is screwed because -- $src = imagecreatefromjpeg($this -> originalFile);-- always assumes the file is going to be a jpeg, but then later he test for different image types. What's the reason for that?And I don't see where he provides the values for $newWidth and $newHeight used in the resample.Here's a simpler example: http://webbytedd.com/b/thumb/ Just add the png type to the header content. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---Jim Thanks for your reponse. With the variable defined. it is supposed to reduce the size of the image before upload. Thanks again. Gary "Jim Lucas" <li...@cmsws.com> wrote in message news:4bdc311b.4060...@cmsws.com... > Gary wrote: >> I have this duplicate code on another site and it works fine. The image >> is uploaded to the images folder, the information is not submitted to the >> database. I get the error >> >> Some Error Occured While Inserting Records >> >> This is only on a local machine so I have not yet included and safegaurds >> like stripslashes or my_real_escape_string. >> >> Thanks for your help >> >> Gary >> >> <?php >> if (isset($_POST['submit'])) { >> $manufacturer=($_POST['manufacturer']); >> $type=($_POST['type']); >> $model=($_POST['model']); >> $caliber=($_POST['caliber']); >> $condition=($_POST['condition']); >> $price=($_POST['price']); >> $description=($_POST['description']); >> $image_file_name=($_POST['image_file_name']); >> $image_file=($_FILES['image_file']); >> $available=($_POST['available']); >> >> $image_file = $_FILES['image_file']['name']; >> $image_type = $_FILES['image_file']['type']; >> $image_size = $_FILES['image_file']['size']; >> >> include ('includes/connect_local.inc.php'); >> > > Is the following line suppose to be working with a constant or the > variable that you defined/extracted just above here? > >> if(image_size >3000000) { >> >> class ImgResizer { >> private $originalFile = 'image_file'; >> public function __construct($originalFile = 'image_file') { >> $this -> originalFile = $originalFile; >> } >> public function resize($newWidth, $targetFile) { >> if (empty($newWidth) || empty($targetFile)) { >> return false; >> } >> $src = imagecreatefromjpeg($this -> originalFile); >> list($width, $height) = getimagesize($this -> originalFile); >> $newHeight = ($height / $width) * $newWidth; >> $tmp = imagecreatetruecolor($newWidth, $newHeight); >> imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, >> $width, $height); >> if (file_exists($targetFile)) { >> unlink($targetFile); >> } >> imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between >> 0 - 100 for output image quality with 100 being the most luxurious >> } >> } >> } >> if (!empty($type) && !empty($image_file)) { >> if (($image_type == 'image/gif') || ($image_type == 'image/jpeg') >> || ($image_type == 'image/pjpeg') || ($image_type == 'image/png') && > > By the use of a variable below, I'm guessing it was suppose to be a > variable. > >> ($image_size <3000000)) { >> if ($_FILES['image_file']['error'] == 0) { >> // Move the file to the target upload folder >> $target = 'images/' . $image_file; >> if (move_uploaded_file($_FILES['image_file']['tmp_name'], >> $target)){ >> $batchconnection; >> >> $sqlStatements = "INSERT INTO guns( id,manufacturer, type, model, >> caliber, condition, price, description, image_file_name,submitted >> ,available) VALUES ('','$manufacturer', '$type', '$model', '$caliber', >> '$condition', '$price', '$description','$image_file_name', ' ', >> '$available'); >> >> INSERT INTO images (id, image_file) VALUES('','$image_file')"; >> >> $sqlResult = $batchconnection->multi_query($sqlStatements); >> if($sqlResult == true) { >> echo "Successfully Inserted Records"; >> } else { >> echo "Some Error Occured While Inserting Records"; >> } >> >> >> >> } >> >> } >> } >> } >> mysqli_close($batchconnection); >> } >> ?> __________ Information from ESET Smart Security, version of virus >> signature database 5076 (20100430) __________ >> >> The message was checked by ESET Smart Security. >> >> http://www.eset.com >> >> >> >> >> > > > -- > Jim Lucas > > A: Maybe because some people are too annoyed by top-posting. > Q: Why do I not get an answer to my question(s)? > A: Because it messes up the order in which people normally read text. > Q: Why is top-posting such a bad thing? > > __________ Information from ESET Smart Security, version of virus > signature database 5077 (20100501) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > __________ Information from ESET Smart Security, version of virus signature database 5077 (20100501) __________ The message was checked by ESET Smart Security. http://www.eset.com
--- End Message ---
--- Begin Message ---At 11:27 AM -0400 5/1/10, Gary wrote:Jim Thanks for your reponse. With the variable defined. it is supposed to reduce the size of the image before upload. Thanks again. GaryGary: That is so wrong!Additionally, you were asked politely to not top post, but you continued to do so. If you expect us to help you but you won't accommodate a simple, and appropriate request, then don't expect any more help from me.bye! tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---Hi tedd Thanks for your reply. I have your http://webbytedd.com/b/thumb/ code inserted, and changed to this: if ( ! isset( $_GET['image_file'] ) ) die( 'Source image not specified' ); $filename = $_GET['image_file']; and I get the 'Source image not specified' error message. I have also tried this $sqlResult = $batchconnection->multi_query($sqlStatements); if($sqlResult == true) { echo "Successfully Inserted Records"; } else { echo "mysql_error()"; } To get the insertion error, but I dont seem to have a handle on it. I just find it curious that the code works for one and not the other. Both local servers are the same, I have compared DB parameters, looked at the code till by eye bleed,,, I just done see it. Gary "tedd" <tedd.sperl...@gmail.com> wrote in message news:p06240801c801f2dad...@[192.168.1.102]... > At 1:45 AM +0100 5/1/10, Ashley Sheridan wrote: >>On Fri, 2010-04-30 at 20:43 -0400, Gary wrote: >> >>> I have this duplicate code on another site and it works fine. The >>> image is >>> uploaded to the images folder, the information is not submitted to the >>> database. I get the error >>> >>> Some Error Occured While Inserting Records >>> >>> This is only on a local machine so I have not yet included and >>> safegaurds >>> like stripslashes or my_real_escape_string. >>> >>> Thanks for your help >>> >>> Gary >>> >>> <?php >>> if (isset($_POST['submit'])) { >>> $manufacturer=($_POST['manufacturer']); >>> $type=($_POST['type']); >>> $model=($_POST['model']); >>> $caliber=($_POST['caliber']); >>> $condition=($_POST['condition']); >>> $price=($_POST['price']); >> > $description=($_POST['description']); >> >>- > > -snip- > >>Is it possible that this server doesn't like batch queries? Try >>splitting them out into individual queries and seeing if that helps. If >>that doesn't do the trick, print out the SQL query string to see if it's >>what you expect. It might be working fine on the other server, but I've >>seen enough strange things happen before to know that sometimes 'poo' >>happens. >> >>Thanks, >>Ash >>http://www.ashleysheridan.co.uk > > Ash: > > 'poo'? Wow, you're becoming quite the Hemingway :-) > > If the OP does clean his $_POST before putting the results in his > database, his database will look like 'poo' if the wrong person comes > along. > > Also, the OP's code reads: > > ($image_type == 'image/pjpeg') || ($image_type == 'image/png') && > > That should be: > > ($image_type == 'image/jpeg') || ($image_type == 'image/png') && > > Regardless of IF the code runs OK somewhere else it won't if it's dealing > with a jpeg or even a jpg image. > > Plus, the logic is screwed because -- > > $src = imagecreatefromjpeg($this -> originalFile); > > -- always assumes the file is going to be a jpeg, but then later he test > for different image types. What's the reason for that? > > And I don't see where he provides the values for $newWidth and $newHeight > used in the resample. > > Here's a simpler example: > > http://webbytedd.com/b/thumb/ > > Just add the png type to the header content. > > Cheers, > > tedd > > > -- > ------- > http://sperling.com http://ancientstones.com http://earthstones.com > > __________ Information from ESET Smart Security, version of virus > signature database 5077 (20100501) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > __________ Information from ESET Smart Security, version of virus signature database 5077 (20100501) __________ The message was checked by ESET Smart Security. http://www.eset.com
--- End Message ---
--- Begin Message ---What is top posting? Gary "tedd" <tedd.sperl...@gmail.com> wrote in message news:p06240803c801ff96d...@[192.168.1.102]... > At 11:27 AM -0400 5/1/10, Gary wrote: >>Jim >> >>Thanks for your reponse. With the variable defined. it is supposed to >>reduce the size of the image before upload. >> >>Thanks again. >> >>Gary > > Gary: > > That is so wrong! > > Additionally, you were asked politely to not top post, but you continued > to do so. If you expect us to help you but you won't accommodate a simple, > and appropriate request, then don't expect any more help from me. > > bye! > > tedd > -- > ------- > http://sperling.com http://ancientstones.com http://earthstones.com > > __________ Information from ESET Smart Security, version of virus > signature database 5077 (20100501) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > __________ Information from ESET Smart Security, version of virus signature database 5077 (20100501) __________ The message was checked by ESET Smart Security. http://www.eset.com
--- End Message ---
--- Begin Message ---> > If the OP does clean his $_POST before putting the results in his database, > his database will look like 'poo' if the wrong person comes along. Gary had mentioned in his initial post he was testing on a local machine and would add the checks after resolving this issue. > Also, the OP's code reads: ($image_type == 'image/pjpeg') || ($image_type == 'image/png') && That should be: ($image_type == 'image/jpeg') || ($image_type == 'image/png') && Tedd, Gary's original code does include jpeg AND pjpeg types (if you omit pjpeg's, you'll miss some images.) That said, Gary, Tedd did point out some important issues with the logic in your code. Additionally, you were asked politely to not top post, but you continued to > do so. If you expect us to help you but you won't accommodate a simple, and > appropriate request, then don't expect any more help from me. > bye! Where was he asked to avoid top-posting in this thread? What is top posting? Gary, top-posting is when you add your content to an email thread at the top (as opposed to the bottom) of the email message. The preferred method of this list's admins is that you add your reply to the bottom of the message thread. So, in future posts, please try to remember to add your message to the bottom of the thread instead of the top. Thanks :) Gary, what is the INSERT line for the images table supposed to be (it looks like it got mangled in your copying and pasting?) $sqlStatements = "INSERT INTO guns( id,manufacturer, type, model, caliber, condition, price, description, image_file_name,submitted ,available) VALUES ('','$manufacturer', '$type', '$model', '$caliber', '$condition', '$price', '$description','$image_file_name', ' ', '$available'); > INSERT INTO images (id, image_file) VALUES('','$image_file')"; > $sqlResult = $batchconnection->multi_query($sqlStatements); if($sqlResult == true) { echo "Successfully Inserted Records"; } else { echo "Some Error Occured While Inserting Records"; } Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
--- End Message ---
--- Begin Message ---On Fri, Apr 30, 2010 at 7:33 PM, Nick Balestra <n...@beyounic.com> wrote: > thanks Piero! > > i was trying to solve an excercise on "learning php5" (O'reilyl) book. > > I am happy abotut his solution with the array_sum funtion you suggested, > and my multidimensional array make much more sense to mee then they > suggested solution that also much more line of code comapred... > > look: my solution (with Piero suggeston): and ont he bottom the book > solution. what do u say is the best one? why? i am learning so i am > interested in understanding why a solution can be better then an other... > > $us_census = array('NY' => array('New York' => 8008278), > 'CA' => array('Los Angeles' => 3694820, > 'San Diego' > => 1223400), > 'IL' => array('Chicago' => 2896016), > 'TX' => array('Houston' => 1953631, > 'Dallas' => > 1188580, > 'San > Antonio' => 1144646), > 'PA' => array('Philadelphia' => 1517550), > 'AZ' => array('Phoenix' => 1321045), > 'MI' => array('Detroit' => 951270)); > > > > print > "<table><tr><th>State</th><th>City</th><th>Population</th><th>Total</th></tr>"; > > > foreach ($us_census as $state => $cities) { > > foreach ($cities as $city => $habitants){ > > $tothabitants += $habitants; > > print > "<tr><td>$state</td><td>$city</td><td>$habitants</td><td></td></tr>"; > } > } > > print "<tr><td></td><td></td><td></td><td>$tothabitants</td></tr></table>"; > > > foreach ($us_census as $state => $cities) { > $population_per_state = array_sum($cities); > print "$state $population_per_state<br>"; > } > > -------------------------- > the book solution: > > > $population = array('New York' => array('state' => 'NY', 'pop' => 8008278), > 'Los Angeles' => array('state' => 'CA', 'pop' => 3694820), > 'Chicago' => array('state' => 'IL', 'pop' => 2896016), > 'Houston' => array('state' => 'TX', 'pop' => 1953631), > 'Philadelphia' => array('state' => 'PA', 'pop' => 1517550), > 'Phoenix' => array('state' => 'AZ', 'pop' => 1321045), > 'San Diego' => array('state' => 'CA', 'pop' => 1223400), > 'Dallas' => array('state' => 'TX', 'pop' => 1188580), > 'San Antonio' => array('state' => 'TX', 'pop' => 1144646), > 'Detroit' => array('state' => 'MI', 'pop' => 951270)); > > $state_totals = array( ); > $total_population = 0; > print "<table><tr><th>City</th><th>Population</th></tr>\n"; > foreach ($population as $city => $info) { > > > $total_population += $info['pop']; > > $state_totals[$info['state']] += $info['pop']; > print "<tr><td>$city, {$info['state']}</td><td>{$info['pop']}</td></tr>\n"; > } > > foreach ($state_totals as $state => $pop) { > print "<tr><td>$state</td><td>$pop</td>\n"; > } > print "<tr><td>Total</td><td>$total_population</td></tr>\n"; > print "</table>\n"; > > > > > I actually prefer your solution - it's easier to read and understand. On the other hand the solution the book offers has the advantage of being more extensible in that more pieces of information can be added per city. One thing I dont like about both solutions is that they both intertwine computation logic with presentation. A *much* better approach in this case is to first calculate all population data you need and put together one data structure that has all of that. Only after you have that ready do you begin to output HTML. And while outputting HTML the only PHP you should need is to iterate over your data structure and output. -- http://programming-guides.com
--- End Message ---
--- Begin Message ---Thanks! I'll agree with you abotu ur points, i just started php few days ago..so i am in the first phase of learnign it...and this list is so gr8! thanks evrybody cheers, Nick On May 1, 2010, at 6:11 PM, Programming Guides wrote: > On Fri, Apr 30, 2010 at 7:33 PM, Nick Balestra <n...@beyounic.com> wrote: > thanks Piero! > > i was trying to solve an excercise on "learning php5" (O'reilyl) book. > > I am happy abotut his solution with the array_sum funtion you suggested, and > my multidimensional array make much more sense to mee then they suggested > solution that also much more line of code comapred... > > look: my solution (with Piero suggeston): and ont he bottom the book > solution. what do u say is the best one? why? i am learning so i am > interested in understanding why a solution can be better then an other... > > $us_census = array('NY' => array('New York' => 8008278), > 'CA' => array('Los Angeles' => 3694820, > 'San Diego' > => 1223400), > 'IL' => array('Chicago' => 2896016), > 'TX' => array('Houston' => 1953631, > 'Dallas' => > 1188580, > 'San Antonio' > => 1144646), > 'PA' => array('Philadelphia' => 1517550), > 'AZ' => array('Phoenix' => 1321045), > 'MI' => array('Detroit' => 951270)); > > > > print > "<table><tr><th>State</th><th>City</th><th>Population</th><th>Total</th></tr>"; > > > foreach ($us_census as $state => $cities) { > > foreach ($cities as $city => $habitants){ > > $tothabitants += $habitants; > > print > "<tr><td>$state</td><td>$city</td><td>$habitants</td><td></td></tr>"; > } > } > > print "<tr><td></td><td></td><td></td><td>$tothabitants</td></tr></table>"; > > > foreach ($us_census as $state => $cities) { > $population_per_state = array_sum($cities); > print "$state $population_per_state<br>"; > } > > -------------------------- > the book solution: > > > $population = array('New York' => array('state' => 'NY', 'pop' => 8008278), > 'Los Angeles' => array('state' => 'CA', 'pop' => 3694820), > 'Chicago' => array('state' => 'IL', 'pop' => 2896016), > 'Houston' => array('state' => 'TX', 'pop' => 1953631), > 'Philadelphia' => array('state' => 'PA', 'pop' => 1517550), > 'Phoenix' => array('state' => 'AZ', 'pop' => 1321045), > 'San Diego' => array('state' => 'CA', 'pop' => 1223400), > 'Dallas' => array('state' => 'TX', 'pop' => 1188580), > 'San Antonio' => array('state' => 'TX', 'pop' => 1144646), > 'Detroit' => array('state' => 'MI', 'pop' => 951270)); > > $state_totals = array( ); > $total_population = 0; > print "<table><tr><th>City</th><th>Population</th></tr>\n"; > foreach ($population as $city => $info) { > > > $total_population += $info['pop']; > > $state_totals[$info['state']] += $info['pop']; > print "<tr><td>$city, {$info['state']}</td><td>{$info['pop']}</td></tr>\n"; > } > > foreach ($state_totals as $state => $pop) { > print "<tr><td>$state</td><td>$pop</td>\n"; > } > print "<tr><td>Total</td><td>$total_population</td></tr>\n"; > print "</table>\n"; > > > > > > I actually prefer your solution - it's easier to read and understand. On the > other hand the solution the book offers has the advantage of being more > extensible in that more pieces of information can be added per city. > > One thing I dont like about both solutions is that they both intertwine > computation logic with presentation. A *much* better approach in this case is > to first calculate all population data you need and put together one data > structure that has all of that. Only after you have that ready do you begin > to output HTML. And while outputting HTML the only PHP you should need is to > iterate over your data structure and output. > > -- > http://programming-guides.com
--- End Message ---
--- Begin Message ---Hello everyone, Just a basic question. I have my class starting like this: Class OireMail { // these are required public $smtp_server=""; public $domain=""; public $from=""; public $login=""; public $pass=""; And then go the function themselves. I was told that it's better to put the initial variables in the __construct() function. What are the advantages of doing that and if I need to do it, how would I call the class from another file then? Thanks! -- With best regards from Ukraine, Andre Http://oire.org/ - The Fantasy blogs of Oire Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: http://twitter.com/m_elensule
--- End Message ---
--- Begin Message ---On 05/01/2010 10:23 PM, Andre Polykanine wrote:Hello everyone, Just a basic question. I have my class starting like this: Class OireMail { // these are required public $smtp_server=""; public $domain=""; public $from=""; public $login=""; public $pass=""; And then go the function themselves. I was told that it's better to put the initial variables in the __construct() function. What are the advantages of doing that and if I need to do it, how would I call the class from another file then? Thanks!The advantages of initializing the variables in __construct() is that whenever an object of the class is created, the variables have the values you expect.If you don't put them in __construct(), you will have to create another method which will have to be called after you have created the object using the new operator.Ultimately its the same thing, __construct() is called automatically, only that's the difference.-- Nilesh Govindarajan Site & Server Administrator www.itech7.com मेरा भारत महान ! मम भारत: महत्तम भवतु !
--- End Message ---
--- Begin Message ---tImeArrived = CDate(InputBox("Enter START time:", "Start time", "9:00 AM")) TimeLeft = CDate(InputBox("Enter END time:", "End time", "1:24 PM")) Minutes = DateDiff("n", TimeArrived, TimeLeft) Hours = Int(Minutes / 60) Minutes = Minutes - (Hours * 60) TotalTime = Format(Hours, "0") & ":" & Format(Minutes, "00") I did something like this in VBA, but I want to create something for PHP. How can extract an am or pm from the input string, convert to 24 hours for calculations, then convert back to 12 hour am/pm format in PHP? I want to be able to put 9:00 am as Time Arrived, and 1:00 PM as Time Left, then it puts in the subject the total time i worked on X project. IN VBA thier is time diff function, how do I create something like that that will create a email message, that is then sent to a suplied email, (i.e. our ticket system). Basically I want to transform my VBA code to PHP, so I can run a similar idea on my Blackberry so other technicians in our office can send a proper email on a blackberry while on call in the road. This is what I did in VBA " Dim OutlookMessage As Outlook.MailItem Set OutlookMessage = Application.CreateItem(olMailItem) MsgBox ("Welecome To Support Email") custname = InputBox("Enter Cust name ", "Enter Cust Name", "Put Cust Name") job = InputBox("Work done", "Work", "Short Discrption") TimeArrived = CDate(InputBox("Enter START time:", "Start time", "9:00 AM")) TimeLeft = CDate(InputBox("Enter END time:", "End time", "1:24 PM")) Minutes = DateDiff("n", TimeArrived, TimeLeft) Hours = Int(Minutes / 60) Minutes = Minutes - (Hours * 60) TotalTime = Format(Hours, "0") & ":" & Format(Minutes, "00") OutlookMessage.Subject = custname & ": " & Date & " " & job OutlookMessage.To = "b...@blah.com" OutlookMessage.CC = "bla...@blah.com" OutlookMessage.Body = custname & " " & Chr(13) & Date & Chr(13) & "A: " & TimeArrived & Chr(13) & "E:" & TimeLeft & Chr(13) & "Total: " & TotalTime & " " & Chr(13) -- " THanks Justin IT-TECH
--- End Message ---