Re: [PHP] ? simple solution for error resulting from upgrade to php5
Thanks Geert That has fixed it, with flying colours! Michael On 19.07.2011, at 10:05, Dr Michael Daly wrote: > Hi > is there a simple solution here, other than reverting to php4? > An upgrade from php5 to php5 has resulted in an error msg in this line: > > if( strlen($db_res ) > 0 ) { isn't this a simple check if $db_res is set? what if you change it to - if (is_object($db_res)) i would not downgrade to php4, but fix the code, it is not that much trouble usually Dr Michael Daly MB, BS GradDip(Integrative Medicine), GradCert(Evidence Based Practice), M Bus(Information Innovation), GradDip(Document Management) 03 9521 0352 0413 879 029 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ? simple solution for error resulting from upgrade to php5
Hi short_query_caching is referenced only once more in the script: if( $query_logging ) do_log("query.log",$PHP_SELF." - ".$q); if (preg_match('/^\s*delete/i', $q)) { $p = $query_db_handle->prepare($q); if (DB::isError($p) && $die_on_error ) { die ("PREPARE:\n".$q . "\n\n" . $p->getMessage() . "\n\n" . $p->getCode()); } $db_res = $query_db_handle->execute($p); if (DB::isError($db_res) && $die_on_error ) { die ("EXECUTE:\n".$q . "\n\n" . $db_res->getMessage() . "\n\n" . $db_res->getCode()); } } else { $db_res = $query_db_handle->query($q); if (DB::isError($db_res) && $die_on_error ) { die ($q . "\n\n" . $db_res->getMessage() . "\n\n" . $db_res->getCode()); } } // Let's cache all single row results and serve those cached values, if // the query string matches exaclty. if( $short_query_caching && is_object($db_res) && $db_res->numRows() == 1 && strlen($q) <= 80) { //do_log("query.log","$PHP_SELF - CACHED $q"); $short_query_cache[str_replace(" ","",$q)] = $db_res ; // print ""; } return $db_res; } Michael On Jul 19, 2011, at 3:05 AM, Dr Michael Daly wrote: > Hi > is there a simple solution here, other than reverting to php4? > An upgrade from php5 to php5 has resulted in an error msg in this > line: > > if( strlen($db_res ) > 0 ) { > > I understand this is bec. php5 is object orientated. It says an > Object of class DB_result could not be converted to a string > > > This is the full function: > > > function pbcs_db_query( $q , $die_on_error=true, $ext_db_handle="" ) { > global $db_handle; > global $db_res; > global $query_logging,$PHP_SELF; > global $short_query_cache,$short_query_caching; > > if( $ext_db_handle == "" ) > $query_db_handle = $db_handle; > else > $query_db_handle = $ext_db_handle; > > if( $short_query_caching && strlen( $q ) < 80 ) { > $db_res = $short_query_cache[str_replace(" ","",$q)]; > if( strlen($db_res ) > 0 ) { > //do_log("object.log","READ: ".$db_res); > //$db_res->resetResultSet( 0 ); > mysql_data_seek( $db_res->result , 0 ); > //do_log("query.log",$PHP_SELF." - FROM-CACHE - ".$q); > > return $db_res; > } > } What does short_query_cache[] contain? Dr Michael Daly MB, BS GradDip(Integrative Medicine), GradCert(Evidence Based Practice), M Bus(Information Innovation), GradDip(Document Management) 03 9521 0352 0413 879 029 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ? simple solution for error resulting from upgrade to php5
Hi is there a simple solution here, other than reverting to php4? An upgrade from php5 to php5 has resulted in an error msg in this line: if( strlen($db_res ) > 0 ) { I understand this is bec. php5 is object orientated. It says an Object of class DB_result could not be converted to a string This is the full function: function pbcs_db_query( $q , $die_on_error=true, $ext_db_handle="" ) { global $db_handle; global $db_res; global $query_logging,$PHP_SELF; global $short_query_cache,$short_query_caching; if( $ext_db_handle == "" ) $query_db_handle = $db_handle; else $query_db_handle = $ext_db_handle; if( $short_query_caching && strlen( $q ) < 80 ) { $db_res = $short_query_cache[str_replace(" ","",$q)]; if( strlen($db_res ) > 0 ) { //do_log("object.log","READ: ".$db_res); // $db_res->resetResultSet( 0 ); mysql_data_seek( $db_res->result , 0 ); //do_log("query.log",$PHP_SELF." - FROM-CACHE - ".$q); return $db_res; } } Thanks Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: search is not case insensitive
I have a fix. Thanks to the list for steering me in the right direction Just in case anyone else is lost, here it is, via use of the CONVERT function to convert the binary data to text which can then be searched case insensitively in mysql: Replace this line: "AND LOWER(C.description) LIKE '%".strtolower($search_for)."%' AND C.start_time > $start_time AND C.start_time < $end_time ORDER BY C.start_time"; with: "AND CONVERT(C.description USING latin1) LIKE '%".($search_for)."%' AND C.start_time > $start_time AND C.start_time < $end_time ORDER BY C.start_time"; (the only bit that changes is the text betw the first two 'ANDS') It comes from PBCS online appointment software. Thanks Michael -Original Message- From: Dr Michael Daly [mailto:g...@holisticgp.com.au] Sent: Sunday, 31 October 2010 3:47 PM To: php-general@lists.php.net Subject: search is not case insensitive Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C". "WHERE A.id = B.user_id AND B.appointment_id = C.id ". "AND LOWER(C.description) LIKE '%".strtolower($search_for)."%' AND C.start_time > $start_time AND C.start_time < $end_time ORDER BY C.start_time"; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search is not case insensitive
thanks for this Ash...I didn't really understand but I do now! unfortunately the fix didn't work, possibly bec the mysql data is in binary format (default then becomes: case sensitive). I got a 'syntax error' result I'll find a mysql forum Michael This isn't a php question but a mysql one. Take out the lower() part of the sql statement, as like is case insensitive by default. Thanks, Ash http://www.ashleysheridan.co.uk ----- Reply message - From: "Dr Michael Daly" Date: Sun, Oct 31, 2010 04:47 Subject: [PHP] search is not case insensitive To: Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C". "WHERE A.id = B.user_id AND B.appointment_id = C.id ". "AND LOWER(C.description) LIKE '%".strtolower($search_for)."%' AND C.start_time > $start_time AND C.start_time < $end_time ORDER BY C.start_time"; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Dr Michael Daly MB, BS GradDip(Integrative Medicine), GradCert(Evidence Based Practice), M Bus(Information Innovation), GradDip(Document Management) 03 9521 0352 0413 879 029 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] search is not case insensitive
Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = "SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C". "WHERE A.id = B.user_id AND B.appointment_id = C.id ". "AND LOWER(C.description) LIKE '%".strtolower($search_for)."%' AND C.start_time > $start_time AND C.start_time < $end_time ORDER BY C.start_time"; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php