php-general Digest 9 Sep 2012 17:00:10 -0000 Issue 7957
php-general Digest 9 Sep 2012 17:00:10 - Issue 7957 Topics (messages 319024 through 319026): Re: a little trickery 319024 by: David McGlone 319025 by: Stuart Dallas 319026 by: David McGlone 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 -- ---BeginMessage--- On Saturday, September 08, 2012 11:19:29 PM David McGlone wrote: On Saturday, September 08, 2012 03:49:27 PM you wrote: ?php function completeImageFilename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); return $matches[0]; } echo 'img src='.completeImageFilename($row['MSL_No']).' /'; ? If you need to extract more than one image filename you should be able to modify that pretty easily. YEOW! LOL I looked at this and I'm very stumped on 1 thing. How in the world did you get $prefix to contain the image name without first assigning it to $prefix? I understand the rest, but. Holy smokes, that's blown my mind. I read about glob() on php.net before I replied, but I believe now it's registering. From what I understand glob works just like opendir() but does everything all in just 1 function. so in your code I realize you passed the variable $prefix into glob, along with the path to the files. This put the path images/property_pics/ and each image name from glob into $prefix you then assigne the value of $glob to $matches. Sound about right? :-) -- Regards David M.---End Message--- ---BeginMessage--- On 9 Sep 2012, at 04:19, David McGlone da...@dmcentral.net wrote: On Saturday, September 08, 2012 03:49:27 PM you wrote: On 8 Sep 2012, at 15:35, David McGlone da...@dmcentral.net wrote: I have a function that reads a directory and gets all the file names of images, and I am wondering if it's possible to concatinate this function withint an image tag. Here's an example I tried. function pictures() { $dir = 'images/property_pics/'; $file = array(); if(is_dir($dir)){ if($open = opendir($dir)){ while (($file = readdir($open)) !== false $file !== .) { $names = substr($file, 9, 20); echo $names; } } closedir($handle); } } $rs = $pager-paginate(); if(!$rs) die(mysql_error()); while($row = mysql_fetch_assoc($rs)) { echo div id='record'; echo span; echo im src = images/$row[$MSL_No]pictures(); What I am trying to do is get the last part of an image name, because I know the $MSL_No is always a 9 character name which matches the image name in but in the database, the last bit of characters are not there so I'm trying to take the last characters of the image name and concatinate them to each image name.. Wow this is harder to explain that I thought. Here's an example In the DB I have a row MSL_No and the contents is: 123456789 In my images folder I have an image named 123456789_R13_1.jpg My goal: get the MSL_No out of the DB and concatenate anything after it so I would end up with the whole image name.. I hope this all made sense. :-/ Is there just one image in the folder that starts with the 9 digit number? In that case it's dead simple (untested code): ?php function completeImageFilename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); return $matches[0]; } echo 'img src='.completeImageFilename($row['MSL_No']).' /'; ? If you need to extract more than one image filename you should be able to modify that pretty easily. YEOW! LOL I looked at this and I'm very stumped on 1 thing. How in the world did you get $prefix to contain the image name without first assigning it to $prefix? I understand the rest, but. Holy smokes, that's blown my mind. :-/ I really can't tell whether you're being sarcastic, so I'll assume you're not. Read about function arguments: http://php.net/functions.arguments -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/---End Message--- ---BeginMessage--- On Sunday, September 09, 2012 03:02:17 PM Stuart Dallas wrote: On 9 Sep 2012, at 04:19, David McGlone da...@dmcentral.net wrote: On Saturday, September 08, 2012 03:49:27 PM you wrote: On 8 Sep 2012, at 15:35, David McGlone da...@dmcentral.net wrote: I have a function that reads a directory and gets all the file names of images, and I am wondering if it's possible to concatinate this function withint an image tag. Here's an example I tried. function pictures() { $dir = 'images/property_pics/'; $file = array(); if(is_dir($dir)){ if($open = opendir($dir)){ while (($file = readdir($open)) !== false $file !== .) { $names =
Re: [PHP] a little trickery
On 9 Sep 2012, at 04:19, David McGlone da...@dmcentral.net wrote: On Saturday, September 08, 2012 03:49:27 PM you wrote: On 8 Sep 2012, at 15:35, David McGlone da...@dmcentral.net wrote: I have a function that reads a directory and gets all the file names of images, and I am wondering if it's possible to concatinate this function withint an image tag. Here's an example I tried. function pictures() { $dir = 'images/property_pics/'; $file = array(); if(is_dir($dir)){ if($open = opendir($dir)){ while (($file = readdir($open)) !== false $file !== .) { $names = substr($file, 9, 20); echo $names; } } closedir($handle); } } $rs = $pager-paginate(); if(!$rs) die(mysql_error()); while($row = mysql_fetch_assoc($rs)) { echo div id='record'; echo span; echo im src = images/$row[$MSL_No]pictures(); What I am trying to do is get the last part of an image name, because I know the $MSL_No is always a 9 character name which matches the image name in but in the database, the last bit of characters are not there so I'm trying to take the last characters of the image name and concatinate them to each image name.. Wow this is harder to explain that I thought. Here's an example In the DB I have a row MSL_No and the contents is: 123456789 In my images folder I have an image named 123456789_R13_1.jpg My goal: get the MSL_No out of the DB and concatenate anything after it so I would end up with the whole image name.. I hope this all made sense. :-/ Is there just one image in the folder that starts with the 9 digit number? In that case it's dead simple (untested code): ?php function completeImageFilename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); return $matches[0]; } echo 'img src='.completeImageFilename($row['MSL_No']).' /'; ? If you need to extract more than one image filename you should be able to modify that pretty easily. YEOW! LOL I looked at this and I'm very stumped on 1 thing. How in the world did you get $prefix to contain the image name without first assigning it to $prefix? I understand the rest, but. Holy smokes, that's blown my mind. :-/ I really can't tell whether you're being sarcastic, so I'll assume you're not. Read about function arguments: http://php.net/functions.arguments -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a little trickery
On Sunday, September 09, 2012 03:02:17 PM Stuart Dallas wrote: On 9 Sep 2012, at 04:19, David McGlone da...@dmcentral.net wrote: On Saturday, September 08, 2012 03:49:27 PM you wrote: On 8 Sep 2012, at 15:35, David McGlone da...@dmcentral.net wrote: I have a function that reads a directory and gets all the file names of images, and I am wondering if it's possible to concatinate this function withint an image tag. Here's an example I tried. function pictures() { $dir = 'images/property_pics/'; $file = array(); if(is_dir($dir)){ if($open = opendir($dir)){ while (($file = readdir($open)) !== false $file !== .) { $names = substr($file, 9, 20); echo $names; } } closedir($handle); } } $rs = $pager-paginate(); if(!$rs) die(mysql_error()); while($row = mysql_fetch_assoc($rs)) { echo div id='record'; echo span; echo im src = images/$row[$MSL_No]pictures(); What I am trying to do is get the last part of an image name, because I know the $MSL_No is always a 9 character name which matches the image name in but in the database, the last bit of characters are not there so I'm trying to take the last characters of the image name and concatinate them to each image name.. Wow this is harder to explain that I thought. Here's an example In the DB I have a row MSL_No and the contents is: 123456789 In my images folder I have an image named 123456789_R13_1.jpg My goal: get the MSL_No out of the DB and concatenate anything after it so I would end up with the whole image name.. I hope this all made sense. :-/ Is there just one image in the folder that starts with the 9 digit number? In that case it's dead simple (untested code): ?php function completeImageFilename($prefix) { $matches = glob('images/property_pics/'.$prefix.'*'); return $matches[0]; } echo 'img src='.completeImageFilename($row['MSL_No']).' /'; ? If you need to extract more than one image filename you should be able to modify that pretty easily. YEOW! LOL I looked at this and I'm very stumped on 1 thing. How in the world did you get $prefix to contain the image name without first assigning it to $prefix? I understand the rest, but. Holy smokes, that's blown my mind. :-/ I really can't tell whether you're being sarcastic, so I'll assume you're not. Sorry about that. No sarcasm here. I was so taken aback on how different your code was. I thought I was never going to understand the way you did it vs the way I tried. Sorry about that. Read about function arguments: http://php.net/functions.arguments Thanks. I'll go read it now. :-) -- Regards David M.
Re: [PHP] PHP CURL JSON POST Firebug
On 04/09/2012 19:14, ioan...@btinternet.com wrote: On 04/09/2012 18:41, Matijn Woudt wrote: On Tue, Sep 4, 2012 at 7:35 PM, ioan...@btinternet.com ioan...@btinternet.com wrote: I am hoping someone can spot what is missing here. I am getting null result from curl-ing a page with json post variables. I try this url in my Firefox browser - http://www.targetsite.com/search.php#somevar.someothervar (#somevar.someothervar are irrelevant, I think, as I get the curl variables from Firebug below.) In Firebug, this shows: POST http://www.targetsite.com/ajax/search.xml In Firebug, below this link are tabs for: Headers, Post, Response, XML and Cookies. Post tab shows like: JSON VAR1 1 VAR2 2012-09-12 VAR3 null CACHED [] OPTIONSnull To prove there is output, the Firebug Response tab shows: ?xml version=1.0 encoding=utf-8? JSON various JSON encoded stuff /JSON The above is what I am trying to curl. My php code: $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); //target page from Firebug above: curl_setopt($ch, CURLOPT_URL, http://www.targetsite.com/ajax/search.xml;); //I was not sure how to represent CACHED [], so set it to null try CACHED=array() $data = array( VAR1 = 1, VAR2 = 2012-09-12, VAR3 = null, CACHED=null, OPTIONS=null, ); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //make the request $result = curl_exec($ch); //this returns null Any ideas where to go with this? Maybe I need to include the Cookies? I use the above php and curl functions normally so it's all installed on the server. John It might be that the site is using sessions/cookies. Have a look at the header data with firebug. Not sure if that's the problem, to find out what's really going on, call echo curl_error($ch); after curl_exec to find out what went wrong exactly. If you still don't know how to proceed, paste the result of the curl_error call in your reply. - Matijn I added the cookies to the post array. I changed php array to CACHED=array() for the JSON CACHED:[], and corrected php's null to NULL. It is not returning any error. The browser was showing 'resource not present' before I added the cookies to the post array, now it just returns null $result. Looks like I am transcribing something incorrectly. John I eventually sorted this out. Solution involved: POST params needed to be json_encoded $params=json_encode(array( name = value )); Thanks to http://www.lornajane.net/posts/2011/posting-json-data-with-php-curl curl_setopt($ch, CURLOPT_CUSTOMREQUEST, POST); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); Also, included headers as array and set application type as json: curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($post)) ); Set encoding to auto-detect: curl_setopt( $ch, CURLOPT_ENCODING, ); John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The end of mysql
Then get a new host. A host that disables PDO these days is a host that deserves to go bankrupt. ext/mysql has been dead for years now. --Larry Garfield On 09/08/2012 08:54 AM, Jim Giner wrote: Nope. No PDO as yet either jg On Sep 7, 2012, at 11:22 PM, Adam Richardson simples...@gmail.com wrote: On Fri, Sep 7, 2012 at 9:58 PM, Jim Giner jim.gi...@albanyhandball.com wrote: So with the announced end of the mysql functions (and switching to a different extension), one would think that my isp/hoster would be a bit more interested in my dilemma. I tried today to create my first mysqli-based test script and found that I didn't have that extension. A series of emails with my tech support told me that the shared server farm does not get mysqli - only their business servers. Since I dont' have a need for and want to pay more for a 'business server', I'm told I'm s... outta luck. What about PDO? Is that available? Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The end of mysql
And I didn't see the follow-up messages saying that they do support PDO after all. Crisis averted! :-) I have actually found very few hosts that run ext/mysqli. Everyone I know jumped from ext/mysql to PDO. I've never actually run mysqli myself; at this point everything I do is PDO. --Larry Garfield On 09/09/2012 04:49 PM, Larry Garfield wrote: Then get a new host. A host that disables PDO these days is a host that deserves to go bankrupt. ext/mysql has been dead for years now. --Larry Garfield On 09/08/2012 08:54 AM, Jim Giner wrote: Nope. No PDO as yet either jg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How can I send custom message structures in SoapFault
Hi Has anyone been able to pass custom message structures using SoapFault?. I've tried passing the XML message in the detail parameter but it ends up encoded in the SOAP message. Any ideas? Regards, Néstor Boscán