[PHP-DB] number_format problem
I want to show a number from a database in the format x,xxx.00 in a textfield, then if it is changed by the user I want to post the value of the number to a decimal field. However, once you number_format the number it becomes a string, and numbers like 3,379.90 give a value of 3 when posted to the database, which is hinted at in the notes on number_format. I suppose I need a string to number function - can someone tell me what this might be called please? Regards, John http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] number_format problem
could you cast as a float/double before inserting? $number = (double) $string; don't know what would happen to the comma, but i assume it would just get removed?? just a guess/thought Jeff Dillon, John [EMAIL PROTECTED]To: [EMAIL PROTECTED] o.ukcc: Subject: [PHP-DB] number_format problem 11/05/2003 10:29 AM I want to show a number from a database in the format x,xxx.00 in a textfield, then if it is changed by the user I want to post the value of the number to a decimal field. However, once you number_format the number it becomes a string, and numbers like 3,379.90 give a value of 3 when posted to the database, which is hinted at in the notes on number_format. I suppose I need a string to number function - can someone tell me what this might be called please? Regards, John http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] number_format problem
On Wed, 5 Nov 2003, Dillon, John wrote: I want to show a number from a database in the format x,xxx.00 in a textfield, then if it is changed by the user I want to post the value of the number to a decimal field. However, once you number_format the number it becomes a string, and numbers like 3,379.90 give a value of 3 when posted to the database, which is hinted at in the notes on number_format. I suppose I need a string to number function - can someone tell me what this might be called please? I use this: $x['funds'] = (int)preg_replace(/[\$,]/,,$x['funds']); where $x['funds'] contains something like $3,249,555.32, and the end result is an int of 3249555. I drop the cents... you want to keep 'em, change int to float. Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] number_format problem
Great answer... One question though, how would you convert it back to X,xxx.00 format?? Thanks Aleks -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 10:48 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] number_format problem On Wed, 5 Nov 2003, Dillon, John wrote: I want to show a number from a database in the format x,xxx.00 in a textfield, then if it is changed by the user I want to post the value of the number to a decimal field. However, once you number_format the number it becomes a string, and numbers like 3,379.90 give a value of 3 when posted to the database, which is hinted at in the notes on number_format. I suppose I need a string to number function - can someone tell me what this might be called please? I use this: $x['funds'] = (int)preg_replace(/[\$,]/,,$x['funds']); where $x['funds'] contains something like $3,249,555.32, and the end result is an int of 3249555. I drop the cents... you want to keep 'em, change int to float. Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] number_format problem
On Wed, 5 Nov 2003, Aleks @ USA.net wrote: Great answer... One question though, how would you convert it back to X,xxx.00 format?? number_format($variable,2); --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] number_format problem
From: Dillon, John [EMAIL PROTECTED] I want to show a number from a database in the format x,xxx.00 in a textfield, then if it is changed by the user I want to post the value of the number to a decimal field. However, once you number_format the number it becomes a string, and numbers like 3,379.90 give a value of 3 when posted to the database, which is hinted at in the notes on number_format. I suppose I need a string to number function - can someone tell me what this might be called please? If you know it's going to be in a $x,xxx.xx format, then $new_number = preg_replace('/[^0-9.]/','',$old_number); will remove anything that's not a number or decimal point. BUT, since we know that we can't trust it'll come in that format, you may also want to run $rs = preg_match('/[0-9]+\.?([0-9]{1,2})?/',$new_number); //untested :) which _should_ make sure you're not getting a number like xxx.xx.xxx or xx.xx from some tricky user. If $rs is TRUE or 1, then the number is in the correct format. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] number_format problem
From: [EMAIL PROTECTED] could you cast as a float/double before inserting? $number = (double) $string; don't know what would happen to the comma, but i assume it would just get removed?? Everything after and including the first non-number character would be dropped. So $12,000.34 would end up as zero. 12,445 would end up as 12, etc... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Unsuscribe
Unsubscribe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] number_format problem
From: Peter Beckman [EMAIL PROTECTED] On Wed, 5 Nov 2003, Dillon, John wrote: I use this: $x['funds'] = (int)preg_replace(/[\$,]/,,$x['funds']); where $x['funds'] contains something like $3,249,555.32, and the end result is an int of 3249555. I drop the cents... you want to keep 'em, change int to float. I'd be careful of casting it to float. Not sure how this would work, as it may depend upon your database, but say you casted 100 to a float, it'd be acceptable for PHP to store it as 99.9. Now when you throw that into a DECIMAL field in MySQL for example, it may only store 99.99 instead of rounding up. Floating point errors are a pain. Make sure you test before implementing a solution like this. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] number_format problem
sweet. thanks for hte correction. i try, sometimes i fail. :) CPT John W. Holmes To: Dillon, John [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED]cc: [EMAIL PROTECTED] rter.netSubject: Re: [PHP-DB] number_format problem 11/05/2003 11:56 AM Please respond to CPT John W. Holmes From: [EMAIL PROTECTED] could you cast as a float/double before inserting? $number = (double) $string; don't know what would happen to the comma, but i assume it would just get removed?? Everything after and including the first non-number character would be dropped. So $12,000.34 would end up as zero. 12,445 would end up as 12, etc... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Unsuscribe
From: [EMAIL PROTECTED] Unsubscribe No thanks. I like it here. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] number_format problem
From: [EMAIL PROTECTED] sweet. thanks for hte correction. i try, sometimes i fail. :) But trying is half the battle. GI JOE! ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help: do ... while, reverse data query
Hi there, I need to do a loop where the mysql query starts at the bottom and goes up, as if the data was in reverse order. This is for building a category/ sub_category menu. Data structure: (cat_id, cat_sub, cat_name) sample routine: do { $sql = SELECT * FROM categories WHERE cat_id = '$cat'; $go = mysql_num_rows($sql_result); $cat = $row[cat_sub]; $cat_id = $row[cat_id]; } while ( $go == 1); Any ideas how to to start a the end of the database? Thanks for your help! Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help: do ... while, reverse data query
From: Douglas Freake [EMAIL PROTECTED] I need to do a loop where the mysql query starts at the bottom and goes up, as if the data was in reverse order. This is for building a category/ sub_category menu. Data structure: (cat_id, cat_sub, cat_name) sample routine: do { $sql = SELECT * FROM categories WHERE cat_id = '$cat'; $go = mysql_num_rows($sql_result); $cat = $row[cat_sub]; $cat_id = $row[cat_id]; } while ( $go == 1); Any ideas how to to start a the end of the database? Yes, it's called an ORDER BY clause. SELECT * FROM categories WHERE cat_id = '$cat' ORDER BY cat_id DESC ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Select Value with 's
This is a basic question but I am all messed up and need to be straightened out.. Have a select field called customer that works great except when there is a ' in the customer name. Have tried addslash and stripslashes but I think I might be using them wrong. If I addslash to the select value, the value received but the result page is truncated up to the point of the ' . Can someone refresh me on the correct use of add and strip slashes... please?? Thanks Aleks
Re: [PHP-DB] Help: do ... while, reverse data query
you can do it at sql level by using ORDER BY ... DESC like: SELECT * FROM categories WHERE cat_id = '$cat' ORDER BY cat_id DESC and then proceed the returned recordset in 'normal' way (order) -- Douglas Freake wrote: Hi there, I need to do a loop where the mysql query starts at the bottom and goes up, as if the data was in reverse order. This is for building a category/ sub_category menu. Data structure: (cat_id, cat_sub, cat_name) sample routine: do { $sql = SELECT * FROM categories WHERE cat_id = '$cat'; $go = mysql_num_rows($sql_result); $cat = $row[cat_sub]; $cat_id = $row[cat_id]; } while ( $go == 1); Any ideas how to to start a the end of the database? Thanks for your help! Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Value with 's
hi! do not quite understand your problem.. pls post some code? heres a small snippet that should work well... $qry = 'SELECT `customer` FROM `customerList` ORDER BY `customer`'; $res = mysql_query($qry); while($customer = mysql_fetch_object($res)) { echo stripslashes($res-customer).'br'.\n; } hth? _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:12:45 -0500 An: [EMAIL PROTECTED] Betreff: [PHP-DB] Select Value with 's This is a basic question but I am all messed up and need to be straightened out.. Have a select field called customer that works great except when there is a ' in the customer name. Have tried addslash and stripslashes but I think I might be using them wrong. If I addslash to the select value, the value received but the result page is truncated up to the point of the ' . Can someone refresh me on the correct use of add and strip slashes... please?? Thanks Aleks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SQL SERVER 2000 with PHP and FOR XML clause
Hi, Has anybody had any luck using the ODBC libraries in PHP to connect to a SQL Server 2000 database and passing in a SELECT with a FOR XML clause. I keep getting Warning: odbc_execute(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]The FOR XML clause is not allowed in a CURSOR statement., SQL state 37000 in SQLExecute in ... Is there a work around or am I missing something. I have tried doing a prepare and then an execute, as well as just an exec. I have also tried wrapping the SELECT in a stored procedure in the DB hoping that result set would be returned as binary data. Please Help!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Value with 's
Ok.. First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); } ? /select The optional value displays the ['] correctly when I look at the source. When the submit button is clicked, it passes this form value Cid to the Result.php page. First I convert the posted value $FF = $_POST ['Cid']; then I use it in a select statement $Info = mysql_query(select * FROM customer WHERE customer.customer LIKE '$FF' ); When the customer name is all text, it works fine, but when the customer has the ['] In it like St Mary's, the value I get on the Result.php page is St Mary -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:18 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi! do not quite understand your problem.. pls post some code? heres a small snippet that should work well... $qry = 'SELECT `customer` FROM `customerList` ORDER BY `customer`'; $res = mysql_query($qry); while($customer = mysql_fetch_object($res)) { echo stripslashes($res-customer).'br'.\n; } hth? _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:12:45 -0500 An: [EMAIL PROTECTED] Betreff: [PHP-DB] Select Value with 's This is a basic question but I am all messed up and need to be straightened out.. Have a select field called customer that works great except when there is a ' in the customer name. Have tried addslash and stripslashes but I think I might be using them wrong. If I addslash to the select value, the value received but the result page is truncated up to the point of the ' . Can someone refresh me on the correct use of add and strip slashes... please?? Thanks Aleks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Value with 's
From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Value with 's
Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Value with 's
hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Value with 's
Sorry I left out the exact form It is $info = mysql_query( Select * From customer Where customer.customer LIKE 'St Mary's Hospital'); -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:56 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Value with 's
hi ok - than make it this way: $info = mysql_query( Select * From customer Where customer.customer LIKE St Mary's Hospital); anyways - shouldn't it be like this?: $FF = St Mary's Hospital; $info = mysql_query('Select * From customer Where customer.customer LIKE '.$FF.''); _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:01:37 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Sorry I left out the exact form It is $info = mysql_query( Select * From customer Where customer.customer LIKE 'St Mary's Hospital'); -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:56 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Value with 's
Tried both... Still no joy... The statement becomes $info = mysql_query('Select * From customer Where customer.customer LIKE St Mary's Hospital'); Maybe I need to be a little clearer... Seem that the sql statement is now getting the correct value But the extra ['] is confusing it -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:07 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi ok - than make it this way: $info = mysql_query( Select * From customer Where customer.customer LIKE St Mary's Hospital); anyways - shouldn't it be like this?: $FF = St Mary's Hospital; $info = mysql_query('Select * From customer Where customer.customer LIKE '.$FF.''); _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:01:37 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Sorry I left out the exact form It is $info = mysql_query( Select * From customer Where customer.customer LIKE 'St Mary's Hospital'); -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:56 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Value with 's
hi hm - it would help if you'd send us the code where you generate the query _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:23:06 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Tried both... Still no joy... The statement becomes $info = mysql_query('Select * From customer Where customer.customer LIKE St Mary's Hospital'); Maybe I need to be a little clearer... Seem that the sql statement is now getting the correct value But the extra ['] is confusing it -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:07 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi ok - than make it this way: $info = mysql_query( Select * From customer Where customer.customer LIKE St Mary's Hospital); anyways - shouldn't it be like this?: $FF = St Mary's Hospital; $info = mysql_query('Select * From customer Where customer.customer LIKE '.$FF.''); _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:01:37 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Sorry I left out the exact form It is $info = mysql_query( Select * From customer Where customer.customer LIKE 'St Mary's Hospital'); -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:56 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Value with 's
Using your variables and query, the following, based on one of my own functional pages, the following should work: $FF = addslashes($_POST[Cid]); $info = mysql_query(Select * From customer Where customer.customer LIKE '$FF' ); Give it a shot. Hope this helps. Rich -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:29 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi hm - it would help if you'd send us the code where you generate the query _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:23:06 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Tried both... Still no joy... The statement becomes $info = mysql_query('Select * From customer Where customer.customer LIKE St Mary's Hospital'); Maybe I need to be a little clearer... Seem that the sql statement is now getting the correct value But the extra ['] is confusing it -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:07 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi ok - than make it this way: $info = mysql_query( Select * From customer Where customer.customer LIKE St Mary's Hospital); anyways - shouldn't it be like this?: $FF = St Mary's Hospital; $info = mysql_query('Select * From customer Where customer.customer LIKE '.$FF.''); _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:01:37 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Sorry I left out the exact form It is $info = mysql_query( Select * From customer Where customer.customer LIKE 'St Mary's Hospital'); -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:56 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Value with 's
BINGO Thanks Rich... I just realized were I was going wrong with my attempt Of addslashes I forgot to remove the ['s] in the $_POST statement. I had $FF = addslashes($_POST ['Cid']); Thanks for MA and John for your help also Hope to return the favors.. Aleks -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:52 PM To: PHP-DB Subject: RE: [PHP-DB] Select Value with 's Using your variables and query, the following, based on one of my own functional pages, the following should work: $FF = addslashes($_POST[Cid]); $info = mysql_query(Select * From customer Where customer.customer LIKE '$FF' ); Give it a shot. Hope this helps. Rich -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:29 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi hm - it would help if you'd send us the code where you generate the query _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:23:06 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Tried both... Still no joy... The statement becomes $info = mysql_query('Select * From customer Where customer.customer LIKE St Mary's Hospital'); Maybe I need to be a little clearer... Seem that the sql statement is now getting the correct value But the extra ['] is confusing it -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:07 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi ok - than make it this way: $info = mysql_query( Select * From customer Where customer.customer LIKE St Mary's Hospital); anyways - shouldn't it be like this?: $FF = St Mary's Hospital; $info = mysql_query('Select * From customer Where customer.customer LIKE '.$FF.''); _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:01:37 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Sorry I left out the exact form It is $info = mysql_query( Select * From customer Where customer.customer LIKE 'St Mary's Hospital'); -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:56 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the value. The easy fix above works because it uses double quotes around the value and htmlspecialchars() already changes double quotes by default. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List
RE: [PHP-DB] Select Value with 's
You are most welcome, Aleks. Glad it helped. -Original Message- From: Aleks @ USA.net [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 3:01 PM To: 'Hutchins, Richard'; 'PHP-DB' Subject: RE: [PHP-DB] Select Value with 's BINGO Thanks Rich... I just realized were I was going wrong with my attempt Of addslashes I forgot to remove the ['s] in the $_POST statement. I had $FF = addslashes($_POST ['Cid']); Thanks for MA and John for your help also Hope to return the favors.. Aleks -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:52 PM To: PHP-DB Subject: RE: [PHP-DB] Select Value with 's Using your variables and query, the following, based on one of my own functional pages, the following should work: $FF = addslashes($_POST[Cid]); $info = mysql_query(Select * From customer Where customer.customer LIKE '$FF' ); Give it a shot. Hope this helps. Rich -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:29 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi hm - it would help if you'd send us the code where you generate the query _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:23:06 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Tried both... Still no joy... The statement becomes $info = mysql_query('Select * From customer Where customer.customer LIKE St Mary's Hospital'); Maybe I need to be a little clearer... Seem that the sql statement is now getting the correct value But the extra ['] is confusing it -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 2:07 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi ok - than make it this way: $info = mysql_query( Select * From customer Where customer.customer LIKE St Mary's Hospital); anyways - shouldn't it be like this?: $FF = St Mary's Hospital; $info = mysql_query('Select * From customer Where customer.customer LIKE '.$FF.''); _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 14:01:37 -0500 An: 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Sorry I left out the exact form It is $info = mysql_query( Select * From customer Where customer.customer LIKE 'St Mary's Hospital'); -Original Message- From: ma [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:56 PM To: PHP-DB Subject: Re: [PHP-DB] Select Value with 's hi think you should use ' when you create the query and in the SQL-statement for comparison: $qry = 'SELECT * FROM customer WHERE customer.customer LIKE '.$FF.''; _ma # life would be easier if i knew the source code... Von: Aleks @ USA.net [EMAIL PROTECTED] Datum: Wed, 5 Nov 2003 13:52:51 -0500 An: 'CPT John W. Holmes' [EMAIL PROTECTED], 'ma' [EMAIL PROTECTED], 'PHP-DB' [EMAIL PROTECTED] Betreff: RE: [PHP-DB] Select Value with 's Thanks John for the answer But... Now my select statement on the Result.php page errors out when The value has the [']in it. What the select statement looks like now Is Select * From customer Where customer.customer LIKE 'St Mary's Hospital' Error message is Warning mysql_fetch_array(): supplied argument is not a valid MySQL result -Original Message- From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 1:45 PM To: Aleks @ USA.net; 'ma'; 'PHP-DB' Subject: Re: [PHP-DB] Select Value with 's From: Aleks @ USA.net [EMAIL PROTECTED] First I build my select list: SELECT NAME=Cid size=1 OPTION Selected VALUE=All Customers/OPTION ? While ($Site = mysql_fetch_array($S)) { $Sid = $Site[CID]; $SName = htmlspecialchars($Site[Customer]); echo(option value='$SName'$SName/options\n); Easy fix: echo(option value=\$SName\$SName/options\n); Long version: htmlspecialchars() does not change single quotes unless you pass ENT_QUOTES as the second parameter. What you're ending up with is a value such as: value='St. Mary's' which, HTML will interpret as a value of St. Mary and an unknown s' attribute. So, $SName = htmlspecialchars($Site[Customer], ENT_QUOTES); echo(option value='$SName'$SName/options\n); will convert single quotes to HTML entities and not affect the
[PHP-DB] Re: Having problems on search engines.
Hello, I'm having problems surfing to different search engines (e.g. yahoo, google, and the like) since after putting the address to the address bar, it redirects me to another site which is called searchalot.com and makes a prefix of a certain IP address and making the address I input look like it is being done on a query in Javascript... (e.g. 10.206.34.21=?id?www.google.com). Afterwards I am not able to use google or yahoo anymore. Can somebody please help me on this one. How can I remove the redirecting part in Internet Explorer? I have done a lot of workarounds already but it still doesn't work. Have tried removing searchalot entries in the registry editor, even deleted all cookies and temporary internet files, but to no avail. Appreciate any help I'll be getting. Regards.
[PHP-DB] SELECT COUNT - result from two tables
I cannot seem to get a SELECT COUNT for a query from fields in two different tables and a WHERE clause. Does anyone know if this is not possible with php/mysql or am I doing something wrong? I have tried a number of variations on the following code: $sql = SELECT COUNT(*), bandid, bandname, genre FROM bands, genre WHERE genre.genreid=$g AND bands.genreid=genre.genreid ORDER BY bandname ASC; $gen = mysql_fetch_row(mysql_query($sql)); echo $gen[0]; I know from documentation that COUNT works with WHERE clauses...but also from two tables? Thanks everyone - Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard
Re: [PHP-DB] SELECT COUNT - result from two tables
Mark Gordon wrote: I cannot seem to get a SELECT COUNT for a query from fields in two different tables and a WHERE clause. Does anyone know if this is not possible with php/mysql or am I doing something wrong? I have tried a number of variations on the following code: $sql = SELECT COUNT(*), bandid, bandname, genre FROM bands, genre WHERE genre.genreid=$g AND bands.genreid=genre.genreid ORDER BY bandname ASC; $gen = mysql_fetch_row(mysql_query($sql)); echo $gen[0]; I know from documentation that COUNT works with WHERE clauses...but also from two tables? There's no reason it shouldn't work. The best way to troubleshoot these things is to get the query working without the COUNT(*) and make sure it's returning the right number of rows. Are you even sure the query is executing? Maybe it's failing... $result = mysql_query($sql) or die(mysql_error()); $gen = mysql_fetch_row($result); -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Having problems on search engines.
[EMAIL PROTECTED] wrote: Hello, I'm having problems surfing to different search engines (e.g. yahoo, google, and the like) since after putting the address to the address bar, it redirects me to another site which is called searchalot.com and makes a prefix of a certain IP address and making the address I input look like it is being done on a query in Javascript... (e.g. 10.206.34.21=?id?www.google.com). Afterwards I am not able to use google or yahoo anymore. Can somebody please help me on this one. How can I remove the redirecting part in Internet Explorer? I have done a lot of workarounds already but it still doesn't work. Have tried removing searchalot entries in the registry editor, even deleted all cookies and temporary internet files, but to no avail. There's a worm that rewrites your HOST file so instead of going to google you're redirected to another site. Can't recall the name right now, sorry. Hopefully someone can help you offline as it's not a PHP issue. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SELECT COUNT - result from two tables
Yes, query is definitely working without COUNT(*). Even in the most stripped down form, the query fails: $sql = SELECT COUNT(bandid), genre FROM bands, genre; $result=mysql_query($sql); while ($gen=mysql_fetch_row($result)) { echo $gen[1]; } John W. Holmes [EMAIL PROTECTED] wrote: Mark Gordon wrote: I cannot seem to get a SELECT COUNT for a query from fields in two different tables and a WHERE clause. Does anyone know if this is not possible with php/mysql or am I doing something wrong? I have tried a number of variations on the following code: $sql = SELECT COUNT(*), bandid, bandname, genre FROM bands, genre WHERE genre.genreid=$g AND bands.genreid=genre.genreid ORDER BY bandname ASC; $gen = mysql_fetch_row(mysql_query($sql)); echo $gen[0]; I know from documentation that COUNT works with WHERE clauses...but also from two tables? There's no reason it shouldn't work. The best way to troubleshoot these things is to get the query working without the COUNT(*) and make sure it's returning the right number of rows. Are you even sure the query is executing? Maybe it's failing... $result = mysql_query($sql) or die(mysql_error()); $gen = mysql_fetch_row($result); -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard
Re: [PHP-DB] SELECT COUNT - result from two tables
Mark Gordon wrote: Yes, query is definitely working without COUNT(*). Even in the most stripped down form, the query fails: $sql = SELECT COUNT(bandid), genre FROM bands, genre; $result=mysql_query($sql); while ($gen=mysql_fetch_row($result)) { echo $gen[1]; } Fails how? If it echos zero, it's not failing; your query just isn't returning any rows (regardless whether you think it should or not). -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SQL COUNT vs mysql_num_rows
maybe mysql cannot COUNT the result from more than 1 table, hence the mysql_num_rows function - but isn't it good programming practice to get the SQL to do as much work up front? - Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard
Re: [PHP-DB] SELECT COUNT - result from two tables
Putting more than one table in the FROM clause means tables are joined, then at least following problems could arise: - using WHERE clause you can have empty recordset returned and then COUNT conflicts with it because there is actually no any data to be returned; - joining two (or more) tables without using aliases to the equally named columns in the SELECT/WHERE/COUNT clauses will produce error message instead of expecting data; - COUNT(*) wont work if u have equal table names in the tables; If you give us some more detail description of the tables then it will be easier to find where the problem is Boyan -- John W. Holmes wrote: Mark Gordon wrote: Yes, query is definitely working without COUNT(*). Even in the most stripped down form, the query fails: $sql = SELECT COUNT(bandid), genre FROM bands, genre; $result=mysql_query($sql); while ($gen=mysql_fetch_row($result)) { echo $gen[1]; } Fails how? If it echos zero, it's not failing; your query just isn't returning any rows (regardless whether you think it should or not). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem
A bit difficult to debug this without the file included (config.php); providing the error message would also be helpful. At first glance, I'm just wondering what does the dot mean in the table name used in the FROM clause: FROM school.physics_chris_rockets It shouldn't generate a php syntacs error message, but I'm afraid that query wont work boyan -- Jacob Hackamack wrote: Currently there seems to be some problem with syntax of some sort, for some reason I keep getting thrown back parse errors, commenting out the lines just moves the parse error line around. If anybody has any help thanks in advance. ?php include('config.php'); $Period = $_POST[Period]; $Name = $_POST[Name]; $conn = mysql_connect ( $dbhost , $dbuser , $dbpass ); $sql_select = 'SELECT * FROM school.physics_chris_rockets WHERE Period LIKE '.$Period.' AND Visible LIKE Y ORDER by Position, Name, Date'; $result = mysql_query($sql_select); echo 'titlePhysics Sign-Up Input/title'; echo 'form action=processinfo.php method=post name=Insert_Record'; echo 'input type=hidden name=Period value='.$Period.''; echo 'input type=hidden name=Name value='.$Name.''; echo 'h2Welcome '.$Name.', '; echo ' table border=1/table'; $Space = ''; $Data = $dataRow[1] ; echo' th scope=colPosition/th'; echo' th scope=colOpenings/th'; echo' br'; while ( $dataRow = mysql_fetch_row ( $result ) ) { if ($Space != $dataRow[3]) { echo ' br'; echo ' br'; echo 'br'.$dataRow[3].'br'; $Space = $dataRow[3] ; } else { echo 'td/td'; } if ($Data == ) { echo tdOpen/td; } else { echo 'br'.$dataRow[1].'br'; } } echo '/tr'; echo '/table'; echo 'div align=right'; echo 'pinput type=submit name=submit value=Sign Up tabindex=12/p'; echo '/form'; ? Jacob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL COUNT vs mysql_num_rows
if tables are joined correctly it shouldn't be any problem to get count of a column, and yes - delegating that task to the database should be more efficient concerning the execution time boyan -- [EMAIL PROTECTED] wrote: maybe mysql cannot COUNT the result from more than 1 table, hence the mysql_num_rows function - but isn't it good programming practice to get the SQL to do as much work up front? - Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem
On Thu, 06 Nov 2003 05:46:03 +0100 Boyan Nedkov [EMAIL PROTECTED] wrote: A bit difficult to debug this without the file included (config.php); providing the error message would also be helpful. At first glance, I'm just wondering what does the dot mean in the table name used in the FROM clause: FROM school.physics_chris_rockets It shouldn't generate a php syntacs error message, but I'm afraid that query wont work boyan -- $conn = mysql_connect ( $dbhost , $dbuser , $dbpass ); $sql_select = 'SELECT * FROM school.physics_chris_rockets WHERE Period LIKE'.$Period.' AND Visible LIKE Y ORDER by Position, Name, Date'; $result = mysql_query($sql_select); If the that the database name is school with a table name of physics_chris_rockets then that query might work but we really need the error that is displayed by php or echo $sql_select and copy and paste that to the mysql console. If it gives an error there, fix the query error, if not look somewhere else. People, Don't not be afraid to display plenty of debug statements. For example make sure that $Period is being set. chanage the line $conn = mysql_connect ( $dbhost , $dbuser , $dbpass ); to $conn = mysql_connect ( $dbhost , $dbuser , $dbpass ) or die(Database error: . mysql_error(); If there is a problem with the database, stop there and print the mysql error message. When you have that working remove the die statement and replace with some good error handling. But really we need the error message... George Patterson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SELECT Count - solved
Thanks for the debug advice - I will start using my_sql_error First I got this error: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause So the correct code ended up: $sql = SELECT COUNT(bandid), genre FROM bands, genre GROUP BY genre; $result=mysql_query($sql) or die(mysql_error()); $num=mysql_fetch_row($result); echo $num[0]; while ($gen=mysql_fetch_row($result)) { echo $gen[1]; } Thanks guys - Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard
[PHP-DB] Problem Solved
Thanks for your help, I was able to go through line by line and fix what was wrong, I guess a simple rewriting of some code solved it because now its better and faster then before. Thank You all. Jacob
[PHP-DB] Adding a log file
I am seeing some errors with a program I wrote and I need to write everything to a log file that the program is doing. The following syntax I KNOW is wrong, but not sure they are important to put here correctly yet. //script addtocart $Addcart (info1, info2) Mysqlquey($addcart) I am seeing random items NOT being added to my shopping cart. The reason, I have no clue. I can pull another catgory of items and the first 20 will do fine, I go back to the first category I have and the script seems to work correctly but the data is not written to the shopping cart. Problem with the shopping cart??? I wouldn't think so. Problem with the add page, I don't see how. So where is the error coming from? No clue, which is why I want to log everything. I use 3 different add pages so that each form uses a different way to add. This works for me, and seems to work rather well. But I need to log everything on the 3 forms to see where the errors are coming from. TIA! Robert ~~~ To rest is to rust. ~~~ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Adding a log file
$Addcart() -- is Addcart() a function (in which case you should remove the dollar sign) or are you specifically trying to do some magic there by running a function whose name is stored in that variable? Bogdan Robert Sossomon wrote: I am seeing some errors with a program I wrote and I need to write everything to a log file that the program is doing. The following syntax I KNOW is wrong, but not sure they are important to put here correctly yet. //script addtocart $Addcart (info1, info2) Mysqlquey($addcart) I am seeing random items NOT being added to my shopping cart. The reason, I have no clue. I can pull another catgory of items and the first 20 will do fine, I go back to the first category I have and the script seems to work correctly but the data is not written to the shopping cart. Problem with the shopping cart??? I wouldn't think so. Problem with the add page, I don't see how. So where is the error coming from? No clue, which is why I want to log everything. I use 3 different add pages so that each form uses a different way to add. This works for me, and seems to work rather well. But I need to log everything on the 3 forms to see where the errors are coming from. TIA! Robert ~~~ To rest is to rust. ~~~ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: [PHP] Re: Adding a log file
Like I said, syntactically bogus, I was trying to write it out fast while I was away from the actual scripts... Like I said, for the MOST part the pieces are working, however on some items it is acting correctly yet the items are not showing up in the shopping cart or in the database anywhere. Here's the script pieces. //addtocart.php $addtocart = insert into store_shoppertrack values('','$_POST[SESSID]','$_POST[sel_item_id]','$_POST[sel_item_qty]', '$_POST[sel_item_price]','$item_desc', now()); mysql_query($addtocart); //redirect to showcart page header(Location: showcart.php); //Additem.php $addtocart = insert into store_shoppertrack values('','$_POST[SESSID]','$_POST[sel_item_name]','$_POST[sel_item_qty] ','$_POST[sel_item_price]','$item_desc', now()); mysql_query($addtocart); //Addspec.php //add info to cart table $addtocart = insert into store_shoppertrack values('','$_POST[SESSID]','$_POST[sel_item_id]','$_POST[sel_item_qty]', '$_POST[sel_item_price]','$_POST[sel_item_desc]', now()); mysql_query($addtocart); //Seestore.php /* The following code allows for the addition of a non-stock item. All information is added automatically to the quoter for the salesman. */ $display_block .= HRInput a new item: form method=post action=\addspec.php\nbsp;nbsp;nbsp;nbsp;Item ID:input type=\text\ name=\sel_item_id\BRDescription:input type=\text\ name=\sel_item_desc\BRQuantity: select name=\sel_item_qty\; $display_block .= option value=\0\0/optionoption value=\1\ selected1/option; for ($i=2; $i 301; $i++){ $display_block .= option value=\$i\$i/option; } $display_block .= /selectinput type=\hidden\ name=\SESSID\ value=\$PHPSESSID\/tdtdinput type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]\BRPrice:input type=\text\ name=\sel_item_price\ size=\5\input type=\submit\ name=\submit\ value=\Add to Cart\/form; $display_block .= HR; /* The following code allows for the addition of a stocked item. All information is added automatically to the quoter for the salesman. */ $display_block .= Input item: form method=post action=\additem.php\nbsp;nbsp;nbsp;nbsp;; $display_block .= Item ID:input type=\text\ name=\sel_item_id\BRQuantity: select name=\sel_item_qty\; $display_block .= option value=\0\0/optionoption value=\1\ selected1/option; for ($i=2; $i 301; $i++){ $display_block .= option value=\$i\$i/option; } $display_block .= /select; $display_block .= input type=\hidden\ name=\SESSID\ value=\$PHPSESSID\/tdtd; $display_block .= input type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]\BRPrice:; $display_block .= input type=\text\ name=\sel_item_price\ size=\5\; $display_block .= input type=\submit\ name=\submit\ value=\Add to Cart\/form; //categories.php $display_block .= trtdform method=post action=\addtocart.php\nbsp;nbsp;nbsp;nbsp;emstrong$item_name /strong - $item_desc/em/tdtdselect name=\sel_item_qty\; $display_block .= option value=\0\0/optionoption value=\1\ selected1/option; for ($i=2; $i 301; $i++){ $display_block .= option value=\$i\$i/option; } $display_block .= /selectinput type=\hidden\ name=\SESSID\ value=\$PHPSESSID\input type=\hidden\ name=\sel_item_id\ value=\$item_id\/tdtdinput type=\hidden\ name=\sel_item_name\ value=\$item_name\input type=\hidden\ name=\sel_item_desc\ value=\$item_desc\input type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]?cat_id=$cat_id\input type=\text\ name=\sel_item_price\ size=\5\ value=\$price\input type=\submit\ name=\submit\ value=\Add to Cart\/form/td ~~~ A bachelor can only chase a girl until she catches him. -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 11:00 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP] Re: Adding a log file $Addcart() -- is Addcart() a function (in which case you should remove the dollar sign) or are you specifically trying to do some magic there by running a function whose name is stored in that variable? Bogdan Robert Sossomon wrote: I am seeing some errors with a program I wrote and I need to write everything to a log file that the program is doing. The following syntax I KNOW is wrong, but not sure they are important to put here correctly yet. //script addtocart $Addcart (info1, info2) Mysqlquey($addcart) I am seeing random items NOT being added to my shopping cart. The reason, I have no clue. I can pull another catgory of items and the first 20 will do fine, I go back to the first category I have and the script seems to work correctly but the data is not written to the shopping cart. Problem with the shopping cart??? I wouldn't think so. Problem with the add page, I don't see how. So where is the error coming from? No clue, which is why I want to log everything. I use 3 different add pages so that each form uses a different way to
Re: [PHP-DB] RE: [PHP] Re: Adding a log file
if you want actual errors that PHP generates and not logic based errors, then writing your own error handling function and calling it with set_error_handler() at the top of your scripts may work for you. in your function you'd just need to use $errorstr, $errorfile and $errline and log it using error_log(). hth jeff Robert Sossomon [EMAIL PROTECTED]To: [EMAIL PROTECTED], [EMAIL PROTECTED] com cc: Subject: [PHP-DB] RE: [PHP] Re: Adding a log file 11/05/2003 11:02 AM Like I said, syntactically bogus, I was trying to write it out fast while I was away from the actual scripts... Like I said, for the MOST part the pieces are working, however on some items it is acting correctly yet the items are not showing up in the shopping cart or in the database anywhere. Here's the script pieces. //addtocart.php $addtocart = insert into store_shoppertrack values('','$_POST[SESSID]','$_POST[sel_item_id]','$_POST[sel_item_qty]', '$_POST[sel_item_price]','$item_desc', now()); mysql_query($addtocart); //redirect to showcart page header(Location: showcart.php); //Additem.php $addtocart = insert into store_shoppertrack values('','$_POST[SESSID]','$_POST[sel_item_name]','$_POST[sel_item_qty] ','$_POST[sel_item_price]','$item_desc', now()); mysql_query($addtocart); //Addspec.php //add info to cart table $addtocart = insert into store_shoppertrack values('','$_POST[SESSID]','$_POST[sel_item_id]','$_POST[sel_item_qty]', '$_POST[sel_item_price]','$_POST[sel_item_desc]', now()); mysql_query($addtocart); //Seestore.php /* The following code allows for the addition of a non-stock item. All information is added automatically to the quoter for the salesman. */ $display_block .= HRInput a new item: form method=post action=\addspec.php\nbsp;nbsp;nbsp;nbsp;Item ID:input type=\text\ name=\sel_item_id\BRDescription:input type=\text\ name=\sel_item_desc\BRQuantity: select name=\sel_item_qty\; $display_block .= option value=\0\0/optionoption value=\1\ selected1/option; for ($i=2; $i 301; $i++){ $display_block .= option value=\$i\$i/option; } $display_block .= /selectinput type=\hidden\ name=\SESSID\ value=\$PHPSESSID\/tdtdinput type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]\BRPrice:input type=\text\ name=\sel_item_price\ size=\5\input type=\submit\ name=\submit\ value=\Add to Cart\/form; $display_block .= HR; /* The following code allows for the addition of a stocked item. All information is added automatically to the quoter for the salesman. */ $display_block .= Input item: form method=post action=\additem.php\nbsp;nbsp;nbsp;nbsp;; $display_block .= Item ID:input type=\text\ name=\sel_item_id\BRQuantity: select name=\sel_item_qty\; $display_block .= option value=\0\0/optionoption value=\1\ selected1/option; for ($i=2; $i 301; $i++){ $display_block .= option value=\$i\$i/option; } $display_block .= /select; $display_block .= input type=\hidden\ name=\SESSID\ value=\$PHPSESSID\/tdtd; $display_block .= input type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]\BRPrice:; $display_block .= input type=\text\ name=\sel_item_price\ size=\5\; $display_block .= input type=\submit\ name=\submit\ value=\Add to Cart\/form; //categories.php $display_block .= trtdform method=post action=\addtocart.php\nbsp;nbsp;nbsp;nbsp;emstrong$item_name/strong - $item_desc/em/tdtdselect name=\sel_item_qty\; $display_block .= option value=\0\0/optionoption value=\1\ selected1/option; for ($i=2; $i 301; $i++){$display_block .= option value=\$i\$i/option; } $display_block .= /selectinput type=\hidden\ name=\SESSID\ value=\$PHPSESSID\input type=\hidden\ name=\sel_item_id\ value=\$item_id\/tdtdinput type=\hidden\ name=\sel_item_name\ value=\$item_name\input type=\hidden\ name=\sel_item_desc\ value=\$item_desc\input type=\hidden\ name=\url\ value=\$_SERVER[PHP_SELF]?cat_id=$cat_id\input type=\text\ name=\sel_item_price\ size=\5\
[PHP-DB] Re: [PHP] php|cruise - do unto others...
From: Becoming Digital [EMAIL PROTECTED] php|cruise is coming this March. Final word on this, I promise! :) I'll be on the cruise, so I'm looking forward to meeting anyone else that'll be there. Contact me offline if you want. I wanted to say think you to all of those that contributed to the cause. I ended up getting $71.03US that helped towards the price. (more donations are still welcome, of course, to offset my empty bank account, now). Thanks to Edward for bringing this up in the first place! ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php