[PHP-DB] MySQL update statement problem
Hi, Apologies if this isn't the right place to ask - but I'm banging my head against the wall with this one! I'm trying to update a record in the table (creation script below) using the following SQL statement: UPDATE shop_customer SET eu_vat_number = SK1234567890 AND vat_amount = 0 AND total_amount = 8.4925 WHERE customer_id = 7 AND hash=dcd5e751 Before running the query the value for eu_vat_number is 'null', vat_amount is 0.085 and total_amount = 8.5775. After I run the query (mysql_affected_rows = 1) the values for vat_amount and total_amount remain the same, but vat_number is changed to 0. I've been looking at this most of the afternoon, and it's probably something really simple but I just can't see it... Any ideas? Thanks in advance for your help... Cheers, Kev -- Server version: 3.23.58 -- PHP Version: 4.3.10 CREATE TABLE `shop_customer` ( `customer_id` int(11) NOT NULL auto_increment, `hash` varchar(8) NOT NULL default '', `first_name` varchar(255) NOT NULL default '', `last_name` varchar(255) NOT NULL default '', `email_address` varchar(255) NOT NULL default '', `member_id` int(11) default NULL, `address1` varchar(255) default NULL, `address2` varchar(255) default NULL, `town` varchar(255) default NULL, `county` varchar(255) default NULL, `postcode` varchar(255) default NULL, `country` int(11) NOT NULL default '0', `eu_vat_number` varchar(15) default NULL, `total_items` int(11) default '0', `net_amount` float default '0', `vat_amount` float default '0', `shipping_amount` float default '0', `total_amount` float default '0', `added` datetime NOT NULL default '-00-00 00:00:00', `payment_received` datetime default NULL, PRIMARY KEY (`customer_id`) ) TYPE=MyISAM AUTO_INCREMENT=8 ; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL update statement problem
You need to separate the SET arguments with commas, not ANDs... It's really doing something like this: UPDATE shop_customer SET eu_vat_number = (SK1234567890 AND vat_amount = 0 AND total_amount = 8.4925) WHERE customer_id = 7 AND hash=dcd5e751 (SK1234567890 AND vat_amount = 0 AND total_amount = 8.4925) evaluates to false (0) , so that's what gets set. Kevin Davies - Bonhurst Consulting wrote: Hi, Apologies if this isn't the right place to ask - but I'm banging my head against the wall with this one! I'm trying to update a record in the table (creation script below) using the following SQL statement: UPDATE shop_customer SET eu_vat_number = SK1234567890 AND vat_amount = 0 AND total_amount = 8.4925 WHERE customer_id = 7 AND hash=dcd5e751 Before running the query the value for eu_vat_number is 'null', vat_amount is 0.085 and total_amount = 8.5775. After I run the query (mysql_affected_rows = 1) the values for vat_amount and total_amount remain the same, but vat_number is changed to 0. I've been looking at this most of the afternoon, and it's probably something really simple but I just can't see it... Any ideas? Thanks in advance for your help... Cheers, Kev -- Server version: 3.23.58 -- PHP Version: 4.3.10 CREATE TABLE `shop_customer` ( `customer_id` int(11) NOT NULL auto_increment, `hash` varchar(8) NOT NULL default '', `first_name` varchar(255) NOT NULL default '', `last_name` varchar(255) NOT NULL default '', `email_address` varchar(255) NOT NULL default '', `member_id` int(11) default NULL, `address1` varchar(255) default NULL, `address2` varchar(255) default NULL, `town` varchar(255) default NULL, `county` varchar(255) default NULL, `postcode` varchar(255) default NULL, `country` int(11) NOT NULL default '0', `eu_vat_number` varchar(15) default NULL, `total_items` int(11) default '0', `net_amount` float default '0', `vat_amount` float default '0', `shipping_amount` float default '0', `total_amount` float default '0', `added` datetime NOT NULL default '-00-00 00:00:00', `payment_received` datetime default NULL, PRIMARY KEY (`customer_id`) ) TYPE=MyISAM AUTO_INCREMENT=8 ; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL update statement problem
Jenaro, You're absolutely right (',' instead of 'and' - schoolboy error!). I've obviously been staring at the screen too long! Strange that MySQL accepted it as a valid statement though. Many thanks for the quick reply. I'm off to have a lie down! :) Thanks and regards, Kevin -Original Message- From: Jenaro Centeno Gómez [mailto:[EMAIL PROTECTED] Sent: 04 March 2006 17:35 To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL update statement problem Maybe I am wrong, biut isn´this the rigth way to do this: UPDATE shop_customer SET eu_vat_number = SK1234567890, vat_amount = 0,total_amount = 8.4925 WHERE customer_id = 7 AND hash=dcd5e751 Sorry, I've not used too much MySQL but this is the rigth way in Oracle, PostgreSQL and SQLServer. Hope this helps. Kevin Davies - Bonhurst Consulting escribió: Hi, Apologies if this isn't the right place to ask - but I'm banging my head against the wall with this one! I'm trying to update a record in the table (creation script below) using the following SQL statement: UPDATE shop_customer SET eu_vat_number = SK1234567890 AND vat_amount = 0 AND total_amount = 8.4925 WHERE customer_id = 7 AND hash=dcd5e751 Before running the query the value for eu_vat_number is 'null', vat_amount is 0.085 and total_amount = 8.5775. After I run the query (mysql_affected_rows = 1) the values for vat_amount and total_amount remain the same, but vat_number is changed to 0. I've been looking at this most of the afternoon, and it's probably something really simple but I just can't see it... Any ideas? Thanks in advance for your help... Cheers, Kev -- Server version: 3.23.58 -- PHP Version: 4.3.10 CREATE TABLE `shop_customer` ( `customer_id` int(11) NOT NULL auto_increment, `hash` varchar(8) NOT NULL default '', `first_name` varchar(255) NOT NULL default '', `last_name` varchar(255) NOT NULL default '', `email_address` varchar(255) NOT NULL default '', `member_id` int(11) default NULL, `address1` varchar(255) default NULL, `address2` varchar(255) default NULL, `town` varchar(255) default NULL, `county` varchar(255) default NULL, `postcode` varchar(255) default NULL, `country` int(11) NOT NULL default '0', `eu_vat_number` varchar(15) default NULL, `total_items` int(11) default '0', `net_amount` float default '0', `vat_amount` float default '0', `shipping_amount` float default '0', `total_amount` float default '0', `added` datetime NOT NULL default '-00-00 00:00:00', `payment_received` datetime default NULL, PRIMARY KEY (`customer_id`) ) TYPE=MyISAM AUTO_INCREMENT=8 ; -- L.A. Jenaro Centeno Gómez Administración de Redes y Bases de Datos Alimentos La Concordia, S.A. de C.V. Loma de Prados No. 1332 Col. La Marimba Lagos de Moreno, Jal. C.P. 47470 Tel.- 01 474 741 92 00 Ext. 9280 La informacion contenida en este mensaje y sus anexos es de caracter privado y confidencial y para el uso exclusivo de la persona o institucion a la cual ha sido enviado y para otros autorizados para recibirlo, por lo que no podra distribuirse sin la autorizacion expresa del remitente. Si usted no es el destinatario a quien este mensaje fue dirigido o si no es un empleado responsable del envio de este mensaje al destinatario, se hace de su conocimiento que cualquier revision, diseminacion, distribucion, copia u otro uso o acto realizado con base en o relacionado con el contenido de este mensaje y sus anexos está estrictamente prohibida y puede ser ilegal. Asimismo, el presente mensaje no representa la manifestacion del consentimiento de ninguna de las partes, por lo que no genera derecho u obligación alguna para ambas sino hasta que sus representantes legales asi lo manifiesten por escrito. Si usted ha recibido este comunicado y sus anexos por error, le solicitamos lo notifique inmediatamente al remitente respondiendo a este correo y borre el presente y sus anexos de su sistema sin conservar copia de los mismos. Se suprimieron acentos y caracteres especiales para legibilidad del mismo. Gracias. Alimentos La Concordia, S.A. de C.V. The information contained in this message and its attachments is private and confidential and is intended solely for the use of the individual or entity to whom it is addressed and others who are authorized to receive it; therefore, its distribution cannot be possible without authorization from the sender. If you are not the intended recipient or an employee responsible for delivering this message to the intended recipient, you are hereby notified that any revision, dissemination, distribution, copying or other use or action based upon or relative to the information contained in this message and its attachments is strictly prohibited and may be unlawful. You are also informed that the contents of this message shall not be considered as an agreement between the parties and shall not bind any of them until their attorneys decide to do so in writing. If you have received this message and its attachments
Re: [PHP-DB] MySQL Update Quandry
This is not the problem. The query fails when there is, as examples, an invalid syntax in the query or the table is not found. However, if the query executes but updates nothing. How can I know when the update has changed a row or not? Not changing a row does not return a failure. Matt's solutions works well. Since the application is hosted and I have limited choices... the mysql_info() does the trick. - Glenn On 11/26/05, Rich Hutchins [EMAIL PROTECTED] wrote: Please forgive me as I've been working with C# recently so my PHP is a little rusty. But if I'm reading this correctly... If your query fails outright, your function is going to return false: if (!(@ mysql_query($query, $connection))) { $this-errors = array(mysql_errno(), mysql_error()); $error = new Error(); $error-logError($this-errors); return false; } At that point, the script will exit and you'll see the error information in your error log. Because the function/script will exit when it encounters a return statement, you wouldn't ever get to the line of code with the mysql_affected_rows() function in it if your SQL did, indeed, error out. It would write to the error log, return false and exit. If the query was successful, but no data was changed, all you're returning is false. That, as you said, doesn't help much. Plus, it's the same result you're returning for a failed query. Pretty ambiguous. Instead of returning false from these functions, maybe returning some sort of status instead would help. For example, if the query fails due to an error write to the error log as you're currently doing, but return -1 instead of false. If the query succeeds, but no data was changed, return a 0 instead of false since false isn't exactly what the result would mean, but 0 is a little closer to what you really mean. If the query was successful, you could still return true or you could return the number of rows affected if you care to have that information. In the calling code, you would have a function to receive the statuses above and display more meaningful information. For example, (pseudocode, of course) if($queryresult == -1){ $msg = The query failed. Check the error log.; }elseif($queryresult == 0){ $msg = The query was successful, but no rows were altered. }else{ $msg = The query was successful. .$queryresult. rows were altered.; } echo $msg; Hope this helps. Rich -Original Message- From: maestro [mailto:[EMAIL PROTECTED] Sent: Friday, November 25, 2005 1:11 PM To: php-db@lists.php.net Subject: [PHP-DB] MySQL Update Quandry Greetings, I am doing an update to a table as such: class DB { function updateMember($email, $password, $postalCode, $language, $id, $word) { ... if (!(@ mysql_query($query, $connection))) { $this-errors = array(mysql_errno(), mysql_error()); $error = new Error(); $error-logError($this-errors); return false; } if (mysql_affected_rows() == 0) { return false; } return true; } } If the user supplies a wrong $word the mysql_affected_rows will be 0 and the method will return false. This is fine. My problem arises when the user supplies data that has not changed. The mysql_affected_rows will be 0 as well. How can I know the difference between an update that fails due to a failed where clause and one that updates nothing? TIA, Glenn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Update Quandry
Please forgive me as I've been working with C# recently so my PHP is a little rusty. But if I'm reading this correctly... If your query fails outright, your function is going to return false: if (!(@ mysql_query($query, $connection))) { $this-errors = array(mysql_errno(), mysql_error()); $error = new Error(); $error-logError($this-errors); return false; } At that point, the script will exit and you'll see the error information in your error log. Because the function/script will exit when it encounters a return statement, you wouldn't ever get to the line of code with the mysql_affected_rows() function in it if your SQL did, indeed, error out. It would write to the error log, return false and exit. If the query was successful, but no data was changed, all you're returning is false. That, as you said, doesn't help much. Plus, it's the same result you're returning for a failed query. Pretty ambiguous. Instead of returning false from these functions, maybe returning some sort of status instead would help. For example, if the query fails due to an error write to the error log as you're currently doing, but return -1 instead of false. If the query succeeds, but no data was changed, return a 0 instead of false since false isn't exactly what the result would mean, but 0 is a little closer to what you really mean. If the query was successful, you could still return true or you could return the number of rows affected if you care to have that information. In the calling code, you would have a function to receive the statuses above and display more meaningful information. For example, (pseudocode, of course) if($queryresult == -1){ $msg = The query failed. Check the error log.; }elseif($queryresult == 0){ $msg = The query was successful, but no rows were altered. }else{ $msg = The query was successful. .$queryresult. rows were altered.; } echo $msg; Hope this helps. Rich -Original Message- From: maestro [mailto:[EMAIL PROTECTED] Sent: Friday, November 25, 2005 1:11 PM To: php-db@lists.php.net Subject: [PHP-DB] MySQL Update Quandry Greetings, I am doing an update to a table as such: class DB { function updateMember($email, $password, $postalCode, $language, $id, $word) { ... if (!(@ mysql_query($query, $connection))) { $this-errors = array(mysql_errno(), mysql_error()); $error = new Error(); $error-logError($this-errors); return false; } if (mysql_affected_rows() == 0) { return false; } return true; } } If the user supplies a wrong $word the mysql_affected_rows will be 0 and the method will return false. This is fine. My problem arises when the user supplies data that has not changed. The mysql_affected_rows will be 0 as well. How can I know the difference between an update that fails due to a failed where clause and one that updates nothing? TIA, Glenn -- 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-DB] MySQL Update Quandry
Greetings, I am doing an update to a table as such: class DB { function updateMember($email, $password, $postalCode, $language, $id, $word) { ... if (!(@ mysql_query($query, $connection))) { $this-errors = array(mysql_errno(), mysql_error()); $error = new Error(); $error-logError($this-errors); return false; } if (mysql_affected_rows() == 0) { return false; } return true; } } If the user supplies a wrong $word the mysql_affected_rows will be 0 and the method will return false. This is fine. My problem arises when the user supplies data that has not changed. The mysql_affected_rows will be 0 as well. How can I know the difference between an update that fails due to a failed where clause and one that updates nothing? TIA, Glenn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mySQL UPDATE
I created a PHP based mailing list that sends out a Bible verse and a quotation each day. Today's verses were: Bible verse of the day: Matthew 17:19-21 Then the disciples came to Jesus privately and said, Why could we not cast it out? And He said to them, Because of the littleness of your faith; for truly I say to you, if you have faith as a mustard seed, you shall say to this mountain, 'Move from here to there,' and it shall move; and nothing shall be impossible to you. But this kind does not go out except by prayer and fasting. ( NASB ) Quiet Time Quotation And Reflection Topic of the day: If you hold the gospel up and you become it's shadow do you fit? In both the Bible verse table and the quotation table is a current verse of the day column that the UPDATE command is suppose to change from a 0 to a 1 so the associated web page will be able to display and a few other functions will know the current verse of the day. The verses are selected randomly. Both the UPDATE for the Bible verse and the UPDATE for the quotation failed. I know the code works over all. From my estimate the use of or ' is the reason why the UPDATE didn't work. Let me show you some code: It selects a Bible verse: SELECT * FROM bible ORDER BY RAND() LIMIT 1 Then it puts the text into variables: $bible_verse_ref=mysql_result($result,$i,bible_verse_ref); $bible_verse_text=mysql_result($result,$i,bible_verse_text); $bible_verse_translation=mysql_result($result,$i,bible_verse_translation); Then immediately following this is the UPDATE that didn't work: UPDATE `bible` SET `current_verse_of_the_day` = '1' WHERE `bible_verse_ref` LIKE '$bible_verse_ref' AND `bible_verse_text` LIKE '$bible_verse_text' AND `bible_verse_translation` LIKE '$bible_verse_translation' AND `current_verse_of_the_day` LIKE '0' LIMIT 1 Where there are no ' or this piece of code works just fine. I am essentially retrieving a Bible verse from the table and then immediately searching for it to change the 'current_verse_of_the_day' to change from 0 to 1. I have manually made the change for today and the current_verse_of_the_day value was 0. Similar code is used for the quotation --- but there is no need for me to repeat it here. Any ideas how I am able to get the use of ' or to work on this page? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mySQL UPDATE
On Thu, 9 Jun 2005, Ron Piggott wrote: I created a PHP based mailing list that sends out a Bible verse and a quotation each day. Today's verses were: [snip] Let me show you some code: It selects a Bible verse: SELECT * FROM bible ORDER BY RAND() LIMIT 1 On a side note, this is going to be expensive... there was a long thread on this just recently, but at the very least do: SELECT COUNT(*) FROM bible; $random_record = rand(0, $value_from_query); SELECT * FROM bible LIMIT 1 OFFSET $random_record; Then it puts the text into variables: $bible_verse_ref=mysql_result($result,$i,bible_verse_ref); $bible_verse_text=mysql_result($result,$i,bible_verse_text); $bible_verse_translation=mysql_result($result,$i,bible_verse_translation); Then immediately following this is the UPDATE that didn't work: UPDATE `bible` SET `current_verse_of_the_day` = '1' WHERE `bible_verse_ref` LIKE '$bible_verse_ref' AND `bible_verse_text` LIKE '$bible_verse_text' AND `bible_verse_translation` LIKE '$bible_verse_translation' AND `current_verse_of_the_day` LIKE '0' LIMIT 1 Where there are no ' or this piece of code works just fine. I am essentially retrieving a Bible verse from the table and then immediately searching for it to change the 'current_verse_of_the_day' to change from 0 to 1. I have manually made the change for today and the current_verse_of_the_day value was 0. Similar code is used for the quotation --- but there is no need for me to repeat it here. Any ideas how I am able to get the use of ' or to work on this page? http://us4.php.net/manual/en/function.mysql-real-escape-string.php Escapes special characters in the unescaped_string, taking into account the current character set of the connection so that it is safe to place it in a mysql_query(). If binary data is to be inserted, this function must be used. mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', and \x1a. This function must always (with few exceptions) be used to make data safe before sending a query to MySQL. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL Update and Sort Queries
hi all, 1) Question on UPDATE My situation is this: I want to update Table1 with values that can be found in Table2.. in short, I would like to do the following: $query = update Table1, Table2 set Table1.field1 = Table2.field2 where Table1.no = Table2.no; however, only MySQL 4.0.4 allows multiple updates and mine is 3.23.54... is there a way to achieve the same effect in one MySQL statement but WITHOUT using this multiple update technique? 2) Question on SORT - I would like to retrive my data from the database in the order which I had inserted it in.. is there a way to tell MySQL NOT to sort it in a certain way?? apparently, the result set i got seem to be sorted according to NAME although I did NOT append my query with an ORDER BY... i'm using phpMyAdmin to view my database records and they are in the order which I inserted them in.. i would like to see this order too when i issue a SELECT on it.. how can I do this? $query2 = select * from GUEST where Hotel = 'PPH'; Thank you so much! I look forward to hearing from you! Hwee :o)
[PHP-DB] MySql Update.
Making an update query that adapts to the number of fields that are to be updated Is there anyway to do like a for loop to create the values part of the query then combine it with the first part of the string. something like what i have below... although something that works correctly as this doesn't. == $table is the table name $num_headers is the number of headers (fieldnames) for that table $table_headers is an array with the names of the headers $values is an array with the names of the input boxes on the previous page == $query1 = UPDATE .$table. SET ; $query2 = ( for ($x=0; $x =$num_headers; $x++){ . $table_headers[$x] . = . $values[$x] . , }) ; $query = $query1.$query2 ; $result = mysql_query ($query) ; etc... _ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySql Update.
$query = UPDATE tablename SET ; foreach($_POST AS $key = $value) $query .= $key = '$value',; $query[strlen($query)-1] = ; $query .= WHERE id = '$_GET[id]'; Or something? On Tue, 2002-11-12 at 13:58, David Rice wrote: Making an update query that adapts to the number of fields that are to be updated Is there anyway to do like a for loop to create the values part of the query then combine it with the first part of the string. something like what i have below... although something that works correctly as this doesn't. == $table is the table name $num_headers is the number of headers (fieldnames) for that table $table_headers is an array with the names of the headers $values is an array with the names of the input boxes on the previous page == $query1 = UPDATE .$table. SET ; $query2 = ( for ($x=0; $x =$num_headers; $x++){ . $table_headers[$x] . = . $values[$x] . , }) ; $query = $query1.$query2 ; $result = mysql_query ($query) ; etc... _ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc signature.asc Description: This is a digitally signed message part
Re: [PHP-DB] MySql Update.
How about: function do_query ($table, $fields, $where) { $sql = 'update ' . $table . ' Set '; foreach ($fields as $k=$v) $sql = $k . ' = \'' . $v . '\','; return mysql_query ($sql); } Not sure if it adapts 100% to your case but you can probably fix it up... Marco -- php|architect - The magazine for PHP Professionals The monthly worldwide magazine dedicated to PHP programmers Come visit us at http://www.phparch.com! ---BeginMessage--- Making an update query that adapts to the number of fields that are to be updated Is there anyway to do like a for loop to create the values part of the query then combine it with the first part of the string. something like what i have below... although something that works correctly as this doesn't. == $table is the table name $num_headers is the number of headers (fieldnames) for that table $table_headers is an array with the names of the headers $values is an array with the names of the input boxes on the previous page == $query1 = UPDATE .$table. SET ; $query2 = ( for ($x=0; $x =$num_headers; $x++){ . $table_headers[$x] . = . $values[$x] . , }) ; $query = $query1.$query2 ; $result = mysql_query ($query) ; etc... _ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL Update failing...
In need of some help. I have a PHP form page that is updating a MySQL database that is not working. Here is the code for the three pages that work together for this application. The oncall_new.php works fine to insert new records into the database, and the oncall_log.php works fine to display the database items. The oncall_update.php is the one that is failing to update the database. I cannot find anything wrong with the code, and I making an initial presentation of this in a couple hours. I was hoping another set of eyes might spot something obvious or simple. Thanks in advance. oncall_new4.php oncall_update1.php oncall_log.php Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Update failing...
I didn't get your attachements. Maybe paste them in a row into the email? -Original Message- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 10:07 AM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] MySQL Update failing... In need of some help. I have a PHP form page that is updating a MySQL database that is not working. Here is the code for the three pages that work together for this application. The oncall_new.php works fine to insert new records into the database, and the oncall_log.php works fine to display the database items. The oncall_update.php is the one that is failing to update the database. I cannot find anything wrong with the code, and I making an initial presentation of this in a couple hours. I was hoping another set of eyes might spot something obvious or simple. Thanks in advance. oncall_new4.php oncall_update1.php oncall_log.php Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Update failing...
Figured it out. Thanks to anyone who started looking at this. The problem was not having my variables in the correct order in the $updateSQL. Once I corrected this, the posting now works fine. -Original Message- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 11:07 AM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] MySQL Update failing... In need of some help. I have a PHP form page that is updating a MySQL database that is not working. Here is the code for the three pages that work together for this application. The oncall_new.php works fine to insert new records into the database, and the oncall_log.php works fine to display the database items. The oncall_update.php is the one that is failing to update the database. I cannot find anything wrong with the code, and I making an initial presentation of this in a couple hours. I was hoping another set of eyes might spot something obvious or simple. Thanks in advance. oncall_new4.php oncall_update1.php oncall_log.php Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL Update command syntax
Correct your example as follows: $sql = UPDATE $table_name SET new_area=\$new_area\; -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 26, 2002 10:49 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL Update command syntax Could anyone help me out with the update command in php? I am trying to update a unique field on a table, or overwrite the current contents of said field. My sql statement is as follows... $db_name = localhost; $table_name = table01; $connection = @mysql_connect(localhost, user, password) or die (Could not connect to database. Please try again later.); $db = @mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = UPDATE $table_name (new_area) VALUES (\$new_area\) ; $result = @mysql_query($sql, $connection) or die (Could not execute query. Please try again later.); My question is if someone could give me an example of the UPDATE command I would appriciate it. Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] MySQL Update Logging ???
NOTES: I know this is a PHP list, but I also know that many of you are experienced MySQL admins. In addition, I was unable to find a MySQL newsgroup, so if you can help me out there, I would appreciated it and would most certainly post my question there. QUESTION: My ISP does not enable update logging with their MySQL server. Is it possible for them or me to turn on update logging just for MY database(s) ??? I appreciate any help God Bless America, Christopher Raymond
Re: [PHP-DB] MySQL Update Logging ???
Check out for MySQL mailing lists http://www.mysql.com/documentation/lists.html -JAson Garber At 03:42 PM 9/20/2001 -0500, Christopher Raymond wrote: NOTES: I know this is a PHP list, but I also know that many of you are experienced MySQL admins. In addition, I was unable to find a MySQL newsgroup, so if you can help me out there, I would appreciated it and would most certainly post my question there. QUESTION: My ISP does not enable update logging with their MySQL server. Is it possible for them or me to turn on update logging just for MY database(s) ??? I appreciate any help God Bless America, Christopher Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] MySQL UPDATE problem
I am having a problem with UPDATE queries with MySQL. Insert, Delete, etc work fine. I have checked the query statement and it works fine directly with MySQL just not in a PHP script. An example function is; function update_gname($gid, $new_name){ $query = UPDATE Groups SET GName=$new_name WHERE GID=$gid; $result = mysql_query($query) or die(error: update_gname()); return $result; } I am using MySQL version 3.22.32 and PHP4.0.3pl1 as a module in Apache1.3.14 with Linux2..2.13. Thanks, Malcolm -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MySQL UPDATE problem
on 8/30/01 4:06 PM, Malcolm White at [EMAIL PROTECTED] wrote: $query = UPDATE Groups SET GName=$new_name WHERE GID=$gid; If the Gname field is a string type, there should probably be quotes around it. $query = 'UPDATE Groups SET GName=' . $new_name . ' WHERE GID=' . $gid; HTH. Sincerely, Paul Burney ++ Paul Burney Webmaster Open Source Developer UCLA - GSEIS - ETU (310) 825-8365 [EMAIL PROTECTED] http://www.gseis.ucla.edu/ ++ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]