Re: [PHP] Update mailing list docs - How to unsubscribe?
On Mon, 23 Jan 2012, Matty Sarro wrote: I have been trying to unsubscribe from this list. I've gone through the directions at http://www.ezmlm.org/ezman/ezman1.html as suggested by http://us.php.net/mailing-lists.php. They don't seem to apply for these lists as written (the method listed for unsubscribing involves sending an email to mailinglist-unsubscr...@example.org, which in this case would be mailinglist-unsubscr...@lists.php.net which sends back a lovely invalid email address response). list-unsubscribe: mailto:php-general-unsubscr...@lists.php.net Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update von php 4.4.6 zu 5.2.8
Merlin Morgenstern wrote: Hello everybody, I want to upgrade my system and do face some trouble with pdflib. compile says: Notice: Following unknown configure options were used: --enable-gd-imgstrttf --with-pdflib I guess the gd functionality is enabled now anyway? How about the pdflib? Is there another command for this? I know there is a free pdf functionality integrated now in php 5, but I would like to stick to the old scripts and use my old pdflib. Is this possible? ./configure --help | grep -i pdflib anything show up as a configure command? maybe it's been renamed (for whatever reason). What does php.net/pdflib say about php5 support? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update does not work...but no errors either
On Sat, May 31, 2008 at 4:23 AM, Ryan S [EMAIL PROTECTED] wrote: Hey, This is my code: == $update_sql=update greetings_final set heading='$heading',message='$message',signature='$signature',font_size='$font_size',font_color='$font_color',bg_color='$bg_color' where temp_cno='.$thecno.' and rand_string='.$randreference.' LIMIT 5; echo $update_sql.brbr; $result2 = mysql_query($update_sql); if(mysql_affected_rows()==0){echo Error R093d: unable to update greeting;exit;} == Try this: ?php // Shorten sanity for this email. function m($data) { $data = mysql_real_escape_string($data); return $data; } $update_sql = UPDATE greetings_final SET heading='.m($heading).',; $update_sql .= message='.m($message).',signature='.m($signature).',; $update_sql .= font_size='.m($font_size).',font_color='.m($font_color).',; $update_sql .= bg_color='.m($bg_color).' WHERE temp_cno='.m($thecno).' ; $update_sql .= AND rand_string='.m($randreference).' LIMIT 5; $result2 = mysql_query($update_sql) or die(mysql_error()); ? -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update does not work...but no errors either
Hey DB, Thanks for replying, I did solve it though was running a lot of tests and checking a lot of stuff with the fill before i finally added the database stuff... but forgot to include() the connection file :) Thanks for writing though! Cheers! R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
marcelo Wolfgang wrote: Hi all, I'm new to this list and new to php programming so sorry if I do something wrong here :) Ok, now to my problem. I've created a query to update a mysql db, and it isn't working, and it's not throwing me any errors, so I need some help to figure out what's wrong here. My code follows : ? if($_GET['act'] = 'a'){ $action = 1; } else if ($_GET['act'] = 'd'){ $action = 0; } $id = $_GET['id']; mysql_connect(localhost,,) or die (mysql_error()); mysql_select_db (taiomara_emailList); $email_Query = mysql_query(UPDATE 'tb_emails' SET 'bol_active' = $action WHERE `auto_id` = $id); I think you want to use back ticks for the table and column names, not single quotes. (On my keyboard this is to the left of the '1' key) Another good idea when having query problems is to put the query into its own variable and echo it out.. like: $sql = UPDATE `tb_emails` SET `bol_active` = $action WHERE `auto_id` = $id; echo $sqlbr/\n; mysql_close(); ? The page is executed, but it don't update the table ... I've tried with the '' and without it ( the phpmyadmin page is where I got the idea of using the '' ). Any clues ? Also, how can I make a redirect after the query has run ? TIA Marcelo Wolfgang -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
marcelo Wolfgang skrev: Hi all, I'm new to this list and new to php programming so sorry if I do something wrong here :) Ok, now to my problem. I've created a query to update a mysql db, and it isn't working, and it's not throwing me any errors, so I need some help to figure out what's wrong here. My code follows : ? if($_GET['act'] = 'a'){ $action = 1; } else if ($_GET['act'] = 'd'){ $action = 0; } Don't use =, use == (or in some cases ===). = is for assignment. Also, what if $_GET['act'] is neither 'a' or 'd'? $id = $_GET['id']; Again, what if $_GET['id'] is null? mysql_connect(localhost,,) or die (mysql_error()); mysql_select_db (taiomara_emailList); $email_Query = mysql_query(UPDATE 'tb_emails' SET 'bol_active' = $action WHERE `auto_id` = $id); Use backticks if you think you need them In this case you don't $sql = UPDATE `tb_emails` SET `bol_active` = $action WHERE `auto_id` = $id; echo DEBUG: $sql; $email_Query = mysql_query( $sql ); This is how to get the error: if ( !$email_Query ) echo mysql_error(); mysql_close(); ? The page is executed, but it don't update the table ... I've tried with the '' and without it ( the phpmyadmin page is where I got the idea of using the '' ). Any clues ? Also, how can I make a redirect after the query has run ? header(Location: http://www.foobar.com;); Will work as long as you don't print out any output whatsoever to the browser before this line of code. TIA Marcelo Wolfgang /T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
Hi, It's fixed, I think the problem where at the '==' ... I have to remember that in PHP this is like ActionScript. Also, what if $_GET['act'] is neither 'a' or 'd'? Again, what if $_GET['id'] is null? The only way to not be 'a' or 'd' or to be null is if someone mess with url, which should throw an error anyway and not run the query. The link that get me to this page where the code is executed is generated to have these options. Thanks for the reply's -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
2007. 04. 11, szerda keltezéssel 16.57-kor Fredrik Thunberg ezt írta: marcelo Wolfgang skrev: Hi all, I'm new to this list and new to php programming so sorry if I do something wrong here :) Ok, now to my problem. I've created a query to update a mysql db, and it isn't working, and it's not throwing me any errors, so I need some help to figure out what's wrong here. My code follows : ? if($_GET['act'] = 'a'){ $action = 1; } else if ($_GET['act'] = 'd'){ $action = 0; } Don't use =, use == (or in some cases ===). = is for assignment. Also, what if $_GET['act'] is neither 'a' or 'd'? $id = $_GET['id']; Again, what if $_GET['id'] is null? and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen greets Zoltán Németh mysql_connect(localhost,,) or die (mysql_error()); mysql_select_db (taiomara_emailList); $email_Query = mysql_query(UPDATE 'tb_emails' SET 'bol_active' = $action WHERE `auto_id` = $id); Use backticks if you think you need them In this case you don't $sql = UPDATE `tb_emails` SET `bol_active` = $action WHERE `auto_id` = $id; echo DEBUG: $sql; $email_Query = mysql_query( $sql ); This is how to get the error: if ( !$email_Query ) echo mysql_error(); mysql_close(); ? The page is executed, but it don't update the table ... I've tried with the '' and without it ( the phpmyadmin page is where I got the idea of using the '' ). Any clues ? Also, how can I make a redirect after the query has run ? header(Location: http://www.foobar.com;); Will work as long as you don't print out any output whatsoever to the browser before this line of code. TIA Marcelo Wolfgang /T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen I think tha tit will be too much of a hacker effort just to kill a table of contact emails, and also he will have to guess ( is there other way ? ) the table name, but just to be on a safer side: - Is there a way to say that id can only be a number ? something like $id:Number = $_GET['id']? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
Marcelo Wolfgang wrote: and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen I think tha tit will be too much of a hacker effort just to kill a table of contact emails, and also he will have to guess ( is there other way ? ) the table name, but just to be on a safer side: - Is there a way to say that id can only be a number ? something like $id:Number = $_GET['id']? TIA If your id should only have digits in it, use if (! ctype_digit($_GET['id'])) { print invalid parameter error message or exit or whatever; } This doesn't work with negative integers - it really checks to make sure that there are only digits, but it is very handy for validating GET or POST variables. There are other ctype functions as well... Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
2007. 04. 11, szerda keltezéssel 17.36-kor Marcelo Wolfgang ezt írta: and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen I think tha tit will be too much of a hacker effort just to kill a table of contact emails, and also he will have to guess ( is there other way ? ) the table name, but just to be on a safer side: - Is there a way to say that id can only be a number ? something like $id:Number = $_GET['id']? that was just an example, any kind of hacker SQL code can be put there... if $id should be a number typecast it to int like this: $id = (int) $_GET['id']; greets Zoltán Németh TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen Something I just thought, he could do a drop table inside an update statement ? because the query is : UPDATE tb_emails SET bol_active = $action WHERE auto_id = $id so if he changed the $action or the $id, it will be inside the UPDATE, doesn't changing any of the variables to a DROP TABLE just give an error ? TIA Marcelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE and redirect
Marcelo Wolfgang wrote: and what if $_GET['id'] is something like 1; DROP TABLE tb_emails; ?? SQL injection just waits to happen Something I just thought, he could do a drop table inside an update statement ? because the query is : UPDATE tb_emails SET bol_active = $action WHERE auto_id = $id so if he changed the $action or the $id, it will be inside the UPDATE, doesn't changing any of the variables to a DROP TABLE just give an error ? TIA Marcelo No. That's why he put the semi-colon after the 1. It becomes update tb_emails set bol_active = $action where auto_id = 1; drop table tb_emails; That's two separate statements that will be happily executed if you're not careful. Try it (on a scratch table). Lori -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update function for content of existing CD?
Frank Arensmeier wrote: Hello all. I am looking for some ideas on how to design / structure a script which checks for updates on files on a existing CD ROM. Every week, I generate content for a CD ROM containing a large number of html pages and PDF files (the CD is distributed to 20 - 30 dealers for ours) . The PHP script which is doing this is outputting a ZIP compressed archive. This ZIP file is then unpacked and burned on a CD. I am now playing with the idea to provide a check-for-updates function on the CD. Because the ZIP archives are rather large in size (300 MB), I am not able to keep all ZIP files. One or two months back is ok. My idea is to have a db table on MySQL containing checksums for all files of the archive and have a script that is able to compare those lists. (one ZIP archive has about 400 - 500 files) My idea is: On the CD's start page I could have a link like: http://myserver.com/look_for_updates.php?myArchiveName=2006-11-10 this implies an internet connection - why not just give them a website in the first place? then all they have to do is hit refresh. The script will then compare checksums for the files included in the archive 2006-11-10 and checksums for the recent file list. It then outputs a new ZIP file including new and updated files. Do you think that there is another (more elegant) way for doing this? Keep in mind that a ZIP file contains about 400-500 files which means that the table would grow rapidly week by week. In only one year the table would contain roughly 25000 rows of data. /frank --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update or add?
Brian Dunning wrote: I have a table where I want to update each record with today's date as it's hit, or add the record if it's not in there: +--+-++ | id | creation_date | last_hit | +--+-++ I'm trying to do this with a minimum of hits to the db, so rather than first searching to see if a matching record is in there, I thought I'd just go ahead and update the matching record, check to see if it failed, and if it failed then add a new one, like this: $id = $_GET['id']; // Update $query = update table set last_hit=NOW() where id='$id'; $result = mysql_query($query); // Add if(the update failed) { $query = insert into table (id,creation_date,last_hit) values ('$id',NOW(),NOW()); $result = mysql_query($query); } What's the fastest way to check if the update failed? You have a few options as others have pointed out, but I'll post this as an option anyway. Other db's don't have replace into or the on duplicate key option either, so you'd need to do something like this: $query = update ..; $result = mysql_query($query); if (mysql_affected_rows($result) == 0) { // do the insert. } -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Update or add?
I have a table where I want to update each record with today's date as it's hit, or add the record if it's not in there: +--+-++ | id | creation_date | last_hit | +--+-++ I'm trying to do this with a minimum of hits to the db, so rather than first searching to see if a matching record is in there, I thought I'd just go ahead and update the matching record, check to see if it failed, and if it failed then add a new one, like this: $id = $_GET['id']; // Update $query = update table set last_hit=NOW() where id='$id'; $result = mysql_query($query); // Add if(the update failed) { $query = insert into table (id,creation_date,last_hit) values ('$id',NOW(),NOW()); $result = mysql_query($query); } What's the fastest way to check if the update failed? Maybe you should be looking at using REPLACE instead of INSERT or UPDATE. REPLACE will update the record if it exists, OR add it if it doesn't. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update or add?
On Friday 30 June 2006 14:37, Brian Dunning wrote: I have a table where I want to update each record with today's date as it's hit, or add the record if it's not in there: +--+-++ | id | creation_date | last_hit | +--+-++ I'm trying to do this with a minimum of hits to the db, so rather than first searching to see if a matching record is in there, I thought I'd just go ahead and update the matching record, check to see if it failed, and if it failed then add a new one, like this: $id = $_GET['id']; // Update $query = update table set last_hit=NOW() where id='$id'; $result = mysql_query($query); // Add if(the update failed) { $query = insert into table (id,creation_date,last_hit) values ('$id',NOW(),NOW()); $result = mysql_query($query); } What's the fastest way to check if the update failed? This is from the php.net docs. Return Values For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a resource on success, or FALSE on error. For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error. So if($result == 0){ do something; } -- Paul Nowosielski Webmaster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update or add?
Paul Nowosielski wrote: On Friday 30 June 2006 14:37, Brian Dunning wrote: I have a table where I want to update each record with today's date as it's hit, or add the record if it's not in there: +--+-++ | id | creation_date | last_hit | +--+-++ I'm trying to do this with a minimum of hits to the db, so rather than first searching to see if a matching record is in there, I thought I'd just go ahead and update the matching record, check to see if it failed, and if it failed then add a new one, like this: $id = $_GET['id']; // Update $query = update table set last_hit=NOW() where id='$id'; $result = mysql_query($query); // Add if(the update failed) { $query = insert into table (id,creation_date,last_hit) values ('$id',NOW(),NOW()); $result = mysql_query($query); } What's the fastest way to check if the update failed? This is from the php.net docs. Return Values For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a resource on success, or FALSE on error. For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error. So if($result == 0){ do something; } No no no no no! Never like that! What you want is this: if($result === false){ do something; } Never use 0 as a placeholder for false, and never use == to compare boolean values. 0 is an integer, false is a boolean. Using === ensures that result is false, and that it is a boolean that is false. It compares the value AND the type. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update or add?
Good advice , Thank you! -- Paul Nowosielski Webmaster On Friday 30 June 2006 15:45, Adam Zey wrote: Paul Nowosielski wrote: On Friday 30 June 2006 14:37, Brian Dunning wrote: I have a table where I want to update each record with today's date as it's hit, or add the record if it's not in there: +--+-++ | id | creation_date | last_hit | +--+-++ I'm trying to do this with a minimum of hits to the db, so rather than first searching to see if a matching record is in there, I thought I'd just go ahead and update the matching record, check to see if it failed, and if it failed then add a new one, like this: $id = $_GET['id']; // Update $query = update table set last_hit=NOW() where id='$id'; $result = mysql_query($query); // Add if(the update failed) { $query = insert into table (id,creation_date,last_hit) values ('$id',NOW(),NOW()); $result = mysql_query($query); } What's the fastest way to check if the update failed? This is from the php.net docs. Return Values For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a resource on success, or FALSE on error. For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error. So if($result == 0){ do something; } No no no no no! Never like that! What you want is this: if($result === false){ do something; } Never use 0 as a placeholder for false, and never use == to compare boolean values. 0 is an integer, false is a boolean. Using === ensures that result is false, and that it is a boolean that is false. It compares the value AND the type. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update or add?
Hi All, there is not-so-used format of SQL format that is INSERT INTO table SET col1=data1, col2=data2... ON DUPLICATE KEY UPDATE col1=data1, col2=data2...; you have to define a primary or unique key in the table and all will work well. for more info http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html Cheers /V Brian Dunning wrote: I have a table where I want to update each record with today's date as it's hit, or add the record if it's not in there: +--+-++ | id | creation_date | last_hit | +--+-++ I'm trying to do this with a minimum of hits to the db, so rather than first searching to see if a matching record is in there, I thought I'd just go ahead and update the matching record, check to see if it failed, and if it failed then add a new one, like this: $id = $_GET['id']; // Update $query = update table set last_hit=NOW() where id='$id'; $result = mysql_query($query); // Add if(the update failed) { $query = insert into table (id,creation_date,last_hit) values ('$id',NOW(),NOW()); $result = mysql_query($query); } What's the fastest way to check if the update failed? --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Update site through email
Hy guys I'd like to know if there is a way to update a site through sending an email. Something like this, you send an email and the body of the email substitutes a text you use in your site. Igreat apreciate any help since I couldn't find anything on this topic. How much time did you spend looking? A good place to start might be: http://us2.php.net/manual/en/ref.imap.php Where there's a will, theres a way. I imagine it would be fairly easy to do. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update site through email
Hello, At my last job there were several companies that would send us text invoices by email. These email accounts were on a Linux box, and when the mail would come in the message was sent to scripts via STDIN. I'm not sure HOW it was done but I know that it CAN be done. I would be concerned about security in this case. The From: header can be spoofed, as can any other header, so before you do this make sure you have some kind of authentication scheme. Wouldn't want some lamer finding the email address and spamming it with v14gr4 email. -K.Bear Hy guys I'd like to know if there is a way to update a site through sending an email. Something like this, you send an email and the body of the email substitutes a text you use in your site. Igreat apreciate any help since I couldn't find anything on this topic. Thanks, doRodrigo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update site through email
Jim Moseby wrote: Hy guys I'd like to know if there is a way to update a site through sending an email. Something like this, you send an email and the body of the email substitutes a text you use in your site. Igreat apreciate any help since I couldn't find anything on this topic. How much time did you spend looking? A good place to start might be: http://us2.php.net/manual/en/ref.imap.php Where there's a will, theres a way. I imagine it would be fairly easy to do. And or knowing how your mail system works (even if you don't have imap set up). Take like qmail for instance; it's trivial to trigger a script when an email arrives: .qmail-email_address (file) --- |/your/path/here/script.php And when you send an email to '[EMAIL PROTECTED]' it will inject the contents of that email into your script. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update site through email
Nathanael Merrill wrote: I will be on vacation from June 26th through July 17th. I will have limited access to email and will get back to you as soon as I can. Thank you. - nathanael merrill You just made the list Nathanael. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update table to get consecutive Primary keys
On Thursday 08 June 2006 23:58, Antonio Bassinger wrote: Hi All! I've a MySQL table: table (id INT NOT NULL AUTO_INCREMENT, flag TINYINT NOT NULL, msgID VARCHAR(30) NOT NULL, msgName VARCHAR(30), size INT NOT NULL, PRIMARY KEY(id)); If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10. I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4 5 6 ... 9. How do I go about it? Thanks Regards, Antonio Simple. Don't. The whole point of having a numeric primary key is that it is both unique and constant. If you change the primary key, then you have to change every reference to it in every other table as well. You've just defeated the purpose of having a non-user-viewable primary key in the first place. You may as well just use the msgName field, save yourself a column in the database, and still have a huge problem with data integrity. As I said, don't do it. Stick with the numeric ID and don't change it. You gain nothing by re-naming your entire database. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update table to get consecutive Primary keys
Antonio Bassinger wrote: Hi All! I've a MySQL table: table (id INT NOT NULL AUTO_INCREMENT, flag TINYINT NOT NULL, msgID VARCHAR(30) NOT NULL, msgName VARCHAR(30), size INT NOT NULL, PRIMARY KEY(id)); If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10. I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4 5 6 ... 9. How do I go about it? Read this thread: http://marc.theaimsgroup.com/?l=php-generalm=114656385709968w=2 It will tell you this is a really bad idea. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update blues
Jim Sara Feldman wrote: Hi: I have a partially finished app using PHP and MySQL that runs on Mac G4 running System 10.3.9. Undoubtedly, I upgraded too many things all at the same time. Something broke. PHP and MySQL are both running. I can use the latest phpMyADMIN and everything is there in the database, so that should check both PHP and MySQL. Here are the changes in hardware and software: NewOld MacG5G4 SystemTiger (10.4)10.3.9 PHP4.3.104.3.4 MySQL4.1.114.0.17 myAdmin2.6.22.5.4 When I run the app, I get the login page with no difficulty, but that takes me back to the page member.php which attempts to start a session and then from there to check the validity of the login by comparing the login variables to those stored in the database. The attempt to use session_start(); now gets me the the following two warnings: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php:212) in /Library/WebServer/Documents/testit/Logsafe_project/member.php on line 14 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php:212) in /Library/WebServer/Documents/testit/Logsafe_project/member.php on line 14 No cookie is created, so it is not obvious why it is complaining. I suspect something in the apache script for starting php. Can anyone suggest a good place to look? It seems php configuration changed with the upgrade. Your old one had output_buffering turned on in php.ini. Instead of turning it back on you should fix your app, open /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php, go to line 212, something's outputting there something (echo, print, anything outside ?php ?), maybe even a whitespace character. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update blues
On Fri, 2005-05-20 at 23:54, Jim Sara Feldman wrote: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php:212) in /Library/WebServer/Documents/testit/Logsafe_project/member.php on line 14 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php:212) in /Library/WebServer/Documents/testit/Logsafe_project/member.php on line 14 What's the first 20 lines of member.php look like? And what's at line 212 +/- in db_fns.php -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update db with $_POST
On Wed, 2005-03-16 at 16:50 +1000, Ligaya Turmelle wrote: assuming you are using PEAR DB - $result = $db-query(UPDATE items SET (item_name, item_desc, item_price, extraprice) VALUES (?,?,?,?) WHERE item_id = 3, array($_POST['title'], $_POST['description'], $_POST['price'], $_POST['extraprice'])); if (PEAR::isError($result)) { echo Error: There was an error with the query. Message returned: ; die($result-getMessage().' '.$db-getUserInfo().' ')); } Thanks I got it worked out though, I'm going to try this also to see what happens, I'm trying to learn the best I can and when things break and you fix em you learn a lot more. Thanks again. PS this is what I did: $db-query('UPDATE items SET item_name=?, item_desc=?, item_price=?, extraprice=? WHERE item_id = 3', array($_POST['title'], $_POST['description'], $_POST['price'], $_POST['extraprice'])); I've already posted this to the list, but it may not be there yet. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update db with $_POST
assuming you are using PEAR DB - $result = $db-query(UPDATE items SET (item_name, item_desc, item_price, extraprice) VALUES (?,?,?,?) WHERE item_id = 3, array($_POST['title'], $_POST['description'], $_POST['price'], $_POST['extraprice'])); if (PEAR::isError($result)) { echo Error: There was an error with the query. Message returned: ; die($result-getMessage().' '.$db-getUserInfo().' ')); } Should give you some info to tell you what is wrong. Danny Brow wrote: I'm trying to update some form data with this db update query and it's not working, I'm not getting an error either. $db-query(UPDATE items SET item_name = $_POST[title], item_desc = $_POST[description], item_price = $_POST[price], extraprice = $_POST[extraprice] WHERE item_id = 3); I've tried this: $db-query(UPDATE items SET (item_name, item_desc, item_price, extraprice) VALUES (?,?,?,?) WHERE item_id = 3, array($_POST['title'], $_POST['description'], $_POST['price'], $_POST['extraprice'])); Thanks, Dan. -- Respectfully, Ligaya Turmelle Life is a game so have fun -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update of mysql to 4.x
Peter wrote: Hi, i'm thinking of updating my mysql-server from 3.23 to 4.1.10, and i can't find any serious information if i would have to rebuild php too. anybody tryed this already?? system: debian linux, apache 1.3.31, php 4.3.9, mysql 3.23.52 thanks peter Please don't spam the list with multiple messages asking the same question. Before you 'upgrade', ask youself, Do I need to upgrade?. What features do you need in 4.1.x that are not present in 3.x? If the answer to that is 'none', you're probably better off leaving it alone. If you still fell you _have_ to upgrade, think about using the 4.0.x version instead of 4.1.x. If you 'upgrade' to MySQL 4.1.x, and don't go with PHP5, you really haven't done anything for your apps, as you won't be able to take advantage of some of the new features. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update of mysql to 4.x
sorry, i googled again, read nearly every post wich containes mysql and upgrade but i can't find a useful answer in this list. perhaps its me... so my question is still the same, would i have to recompile php or not peter @NG what means need? nobody needs an internet,using mysql4 would just makes things easier (like using nested SELECTS) ... shure there is a lot of spam at the list, i did not asked for reasons for an upgrade because i already knew about that, so the next one who is googling for the problem, gets annoyed of the unuseful answer John Nichel schrieb: Peter wrote: Hi, i'm thinking of updating my mysql-server from 3.23 to 4.1.10, and i can't find any serious information if i would have to rebuild php too. anybody tryed this already?? system: debian linux, apache 1.3.31, php 4.3.9, mysql 3.23.52 thanks peter Please don't spam the list with multiple messages asking the same question. Before you 'upgrade', ask youself, Do I need to upgrade?. What features do you need in 4.1.x that are not present in 3.x? If the answer to that is 'none', you're probably better off leaving it alone. If you still fell you _have_ to upgrade, think about using the 4.0.x version instead of 4.1.x. If you 'upgrade' to MySQL 4.1.x, and don't go with PHP5, you really haven't done anything for your apps, as you won't be able to take advantage of some of the new features. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update of mysql to 4.x
Peter wrote: sorry, i googled again, read nearly every post wich containes mysql and upgrade but i can't find a useful answer in this list. perhaps its me... so my question is still the same, would i have to recompile php or not No, you don't. However, mysql = 4.1 uses new authentication protocol, read http://dev.mysql.com/doc/mysql/en/old-client.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update of mysql to 4.x
Peter wrote: sorry, i googled again, read nearly every post wich containes mysql and upgrade but i can't find a useful answer in this list. perhaps its me... so my question is still the same, would i have to recompile php or not peter @NG what means need? nobody needs an internet,using mysql4 would just makes things easier (like using nested SELECTS) ... shure there is a lot of spam at the list, i did not asked for reasons for an upgrade because i already knew about that, so the next one who is googling for the problem, gets annoyed of the unuseful answer Well then far beit from me to try and help in a manner that is unacceptable to you. Maybe I should just go back to my standard answer... http://www.google.com/search?q=php+upgrade+mysql+4.1 -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update of mysql to 4.1
Peter, I have done this on redhat 7 using an rpm to go from mysql 3.x to 4.x beta in the past and it worked fine without recompiling php. Of course I would try to test this on a non-production server first in case of any serious problems. If you do have to recompile php for some reason don't forget the all important make clean command. I don't know who many times I've forgotten to do that when making major changes to the php binary. -Joe W. Peter wrote: Hi, i'm thinking of updating my mysql-server from 3.23 to 4.1.10, and i can't find any serious information if i would have to rebuild php too. anybody tryed this already?? system: debian linux, apache 1.3.31, php 4.3.9, mysql 3.23.52 thanks peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE
Steve Marquez wrote: I am trying to insert information into the database, have it automatically place an ID Number, then update that particular record and replace the word delete with the link. The mysql_insert_id() does seem to be working. It does put in an id number of 0 However, the code in general gives me an error everytime. It says that it is near 'delete = a href...' Can anyone help me with this? Thanks! -- Steve ?php // log into our local server using the MySQL root user. $dbh = mysql_connect( localhost, username, password ); // select the database. mysql_select_db( imagesdb ) or die ( mysql_error() . \n ); ? -- snip -- ?php //This is for the text description of the gallery and the link $insert_data2 = INSERT into images_upload_description (delete, name, description) VALUES ('delete', 'a href=\http://www.domain.org/gallery/bomb/bottom_images.php?gallery_name=$ga llery_name\ target=\bottom\$name/a', '$description');; $response = mysql_query( $insert_data2, $dbh ); $id_num = mysql_insert_id(); $update_data = UPDATE images_upload_description SET delete = a href=\http://www.domain.org/gallery/admin/delete.php?gallery_name=$gallery_ nameid_num=$id_num\ target=\bottom\Delete/a WHERE id_num = \$id_num\; $response = mysql_query( $update_data, $dbh ); if(mysql_error()) die ('database error'. mysql_error()); ? You forgot to put single quotes around the string that begins 'a href= ... ' in the line beginning: $update_data = UPDATE images_upload_description SET delete = a href=\http://www.domain.org/gallery/admin/delete.php?gallery_name=$gallery_nameid_num=$id_num\; target=\bottom\Delete/a WHERE id_num = \$id_num\; -John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE
On Wed, 15 Dec 2004 10:10:22 -0600, Steve Marquez [EMAIL PROTECTED] wrote: I am trying to insert information into the database, have it automatically place an ID Number, then update that particular record and replace the word delete with the link. `delete` is a reserved word. Try wrapping it with backtics. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE
Quoting Steve Marquez [EMAIL PROTECTED]: I am trying to insert information into the database, have it automatically place an ID Number, then update that particular record and replace the word delete with the link. The mysql_insert_id() does seem to be working. It does put in an id number of 0 However, the code in general gives me an error everytime. It says that it is near 'delete = a href...' $update_data = UPDATE images_upload_description SET delete = a href=\http://www.domain.org/gallery/admin/delete.php?gallery_name=$gallery_ nameid_num=$id_num\ target=\bottom\Delete/a WHERE id_num = \$id_num\; try to change the field name in your database from delete to something else and see if that helps. mysql may be complaining since delete is a reserved keyword. HTH -R'twick This message was sent using IMP, the Internet Messaging Program. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update mysql.so problems
Posted this yesterday, still having problems. I've used various combinations with --with-mysql. I removed all the old mysql binaries and libs from /usr/lib, /usr/include and /usr/bin. I removed the old mysql.so from /usr/lib/php4/ I even went as far as upgrading to PHP5. It is still using the mysql 3.23 client API. I've upgraded the dev server and my laptop to have PHP5 and MySQL 4 successfully but can't manage to get PHP5 to use the MySQL 4 client API. On Jul 20, 2004, at 6:47 PM, Jough P wrote: Greetings all, I upgraded to MySQL 4 on a Redhat Enterprise box. I recompiled PHP 4.3.6 and a look at phpinfo() reveals that the old mysql client API is still being used. So, I moved the mysql.so to my home directory hoping that when did ./configure and make again it would create a new one. Doing an 'ls modules/' revealed that it hadn't. So I changed --with-mysql-dir=/usr to --with-mysql-dir-/usr/local/mysql and ./configure stops and says it can't find the mysql header files. Can anyone help please? My goal is to get a new mysql.so created. Thanks tons!! --Jough -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE...
On Sunday 11 July 2004 08:20, Harlequin wrote: I have a page that successfully calls data from the database based on userID Password combo. No Problems there eh... I display the information in a form, the user is supposed to be updating this information and then hitting submit to update their particular record. But guess what...? No Juice...! Please elaborate on what you mean by No Juice. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* A bachelor is an unaltared male. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE...
Sorry Jason. I'm hitting the submit button at the bottom of the page and getting redirected OK to the next page with no errors but when I query the database directly it isn't updating. -- - Michael Mason Arras People www.arraspeople.co.uk - Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sunday 11 July 2004 08:20, Harlequin wrote: I have a page that successfully calls data from the database based on userID Password combo. No Problems there eh... I display the information in a form, the user is supposed to be updating this information and then hitting submit to update their particular record. But guess what...? No Juice...! Please elaborate on what you mean by No Juice. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* A bachelor is an unaltared male. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE...
On Sunday 11 July 2004 08:33, Harlequin wrote: I'm hitting the submit button at the bottom of the page and getting redirected OK to the next page with no errors but when I query the database directly it isn't updating. Should you be getting errors if there is a problem? IOW *are* you putting in any error checking code? In the code that you posted you are not performing any validation checks on the data sent by the user - this is BAD. You should fix that before you go live with your site. You assigned your query to $sql - this is good, but did you print it out so that you can verify the query is what you expected it to be? One of the first rules of debugging is to gather as much info as possible. Which means printing out every variable of significance. When developing your code ALWAYS enable full error reporting and display errors (or if you prefer log them and read the log). -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Clothes make the man. Naked people have little or no influence on society. - Mark Twain */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE...
Jason. Thanks for pointing out the obvious - I should have trapped errors. Thanks you. I did as you suggest and I get a rather generic response: Sorry, Your Request Could Not Be Executed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Little About Me..., FurtherComments=Nothing To Tell about me., My code now on the 2nd page (once the submit button has been hit) is: ?php $UserID= $_POST['TXT_UserID']; $Comments=$_POST['TXT_Comments']; $FurtherComments= $_POST['TXT_FurtherComments']; $UserMail=$_POST['TXT_UserMail']; $CV= $_POST['TXT_CV']; $sql = UPDATE RegisteredMembers SET Comments=$Comments, FurtherComments=$FurtherComments, $UserMail=UserMail, DocumentData=$CV WHERE UserID='$_POST[TXT_UserID]'; $result = mysql_query($sql) or die (Sorry, Your Request Could Not Be Executed: . mysql_error()); echo $sql; ? Any ideas Jason...? -- - Michael Mason Arras People www.arraspeople.co.uk - Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sunday 11 July 2004 08:33, Harlequin wrote: I'm hitting the submit button at the bottom of the page and getting redirected OK to the next page with no errors but when I query the database directly it isn't updating. Should you be getting errors if there is a problem? IOW *are* you putting in any error checking code? In the code that you posted you are not performing any validation checks on the data sent by the user - this is BAD. You should fix that before you go live with your site. You assigned your query to $sql - this is good, but did you print it out so that you can verify the query is what you expected it to be? One of the first rules of debugging is to gather as much info as possible. Which means printing out every variable of significance. When developing your code ALWAYS enable full error reporting and display errors (or if you prefer log them and read the log). -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Clothes make the man. Naked people have little or no influence on society. - Mark Twain */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE...
On Sunday 11 July 2004 09:00, Harlequin wrote: I did as you suggest and I get a rather generic response: Sorry, Your Request Could Not Be Executed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Little About Me..., FurtherComments=Nothing To Tell about me., My code now on the 2nd page (once the submit button has been hit) is: ?php $UserID= $_POST['TXT_UserID']; $Comments=$_POST['TXT_Comments']; $FurtherComments= $_POST['TXT_FurtherComments']; $UserMail=$_POST['TXT_UserMail']; $CV= $_POST['TXT_CV']; $sql = UPDATE RegisteredMembers SET Comments=$Comments, FurtherComments=$FurtherComments, $UserMail=UserMail, DocumentData=$CV WHERE UserID='$_POST[TXT_UserID]'; $result = mysql_query($sql) or die (Sorry, Your Request Could Not Be Executed: . mysql_error()); echo $sql; ? The obvious first thing to do is to put quotes (') around the data when you're using a text field. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Seeing is deceiving. It's eating that's believing. -- James Thurber */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE...
Laugh...? I nearly wet mesen...! Jason. Thanks very much. Truly...! I looked at it, stared at it, growled at it and then finally realised about 30 seconds before I raed your post: SET Comments='$Comments', What an idiot...! Hey - thanks for your patience mate. I don't suppose you'd care to help me with controlling document types for uploading would you...? I have a field that accepts files but don't want some idiot uploading an executable - I doubt my hosting provider would be too chuffed with that at all. -- - Michael Mason Arras People www.arraspeople.co.uk - Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sunday 11 July 2004 09:00, Harlequin wrote: I did as you suggest and I get a rather generic response: Sorry, Your Request Could Not Be Executed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Little About Me..., FurtherComments=Nothing To Tell about me., My code now on the 2nd page (once the submit button has been hit) is: ?php $UserID= $_POST['TXT_UserID']; $Comments=$_POST['TXT_Comments']; $FurtherComments= $_POST['TXT_FurtherComments']; $UserMail=$_POST['TXT_UserMail']; $CV= $_POST['TXT_CV']; $sql = UPDATE RegisteredMembers SET Comments=$Comments, FurtherComments=$FurtherComments, $UserMail=UserMail, DocumentData=$CV WHERE UserID='$_POST[TXT_UserID]'; $result = mysql_query($sql) or die (Sorry, Your Request Could Not Be Executed: . mysql_error()); echo $sql; ? The obvious first thing to do is to put quotes (') around the data when you're using a text field. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Seeing is deceiving. It's eating that's believing. -- James Thurber */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UPDATE...
On Sunday 11 July 2004 09:28, Harlequin wrote: Jason. Thanks very much. Truly...! I looked at it, stared at it, growled at it and then finally realised about 30 seconds before I raed your post: SET Comments='$Comments', You also have the date and column-name switched: ... $UserMail=UserMail ... I don't suppose you'd care to help me with controlling document types for uploading would you...? I have a field that accepts files but don't want some idiot uploading an executable - I doubt my hosting provider would be too chuffed with that at all. Post details of your problem on a NEW thread. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I'm a mean green mother from outer space -- Audrey II, The Little Shop of Horrors */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] update count
[snip] What is the best way to only do an update if it going to update only one row? I want to protect my code so that it won't accidentally update more than one row. I can do a select first but there must be an easier way. :-) [/snip] Do the update with conditions (this is a SQL question) UPDATE `tblFOO` SET `bar` = 'a_value' WHERE `barID` = '227098762' will only update the record(s) where barID is 227098762 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update count
Bob Lockie wrote: What is the best way to only do an update if it going to update only one row? I want to protect my code so that it won't accidentally update more than one row. I can do a select first but there must be an easier way. :-) UPDATE thisDB.thisTable SET thisTable.thisColumn = 'thisValue' WHERE thisTable.uniqueColumn = 'someUniqueValue' -- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update count
On Wed, 16 Jun 2004 09:40:52 -0400, Bob Lockie [EMAIL PROTECTED] wrote: What is the best way to only do an update if it going to update only one row? You don't say what database you're using. The general way is to use a unique key in the WHERE clause. UPDATE tablename SET foo=1 WHERE id=123 MySQL also lets you use a LIMIT clause that will either limit the number of rows affected by the update, or matched by the WHERE clause depending on the MySQL version. UPDATE tablename SET foo=1 WHERE bar=2 LIMIT 1 -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update count
What is the best way to only do an update if it going to update only one row? You don't say what database you're using. The general way is to use a unique key in the WHERE clause. UPDATE tablename SET foo=1 WHERE id=123 MySQL also lets you use a LIMIT clause that will either limit the number of rows affected by the update, or matched by the WHERE clause depending on the MySQL version. UPDATE tablename SET foo=1 WHERE bar=2 LIMIT 1 -robin The LIMIT clause is perfect but is that standard SQL? I am using MySQL right now but it will be run on another database eventually. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update count
If your table has a primary key, or auto increment field works well and is quick. What is the best way to only do an update if it going to update only one row? I want to protect my code so that it won't accidentally update more than one row. I can do a select first but there must be an easier way. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update problem
The form that is being submitted can only be a POST or a GET not both example: form method=post action=foo.php input type=text name=foo1 input type=submit /form How can you do both? -Blake Maldiv wrote: Hello, I have a php update form which use $_POST and $_GET too. I call the update like this update.php?id=1 And after the user submit the form with new data I use command like this: UPDATE table SET id=$_POST['id'] WHERE $_GET['id']='1'; This code works on localhost with Apache 2, Win XP, and Php 4.3.5 but it doesn't works on my real server(Php 4.3.3, Linux, Apache 1.??) I debuged it and I realised that on localhost I have the correct value in the $_GET but in remote $_GET is empty. What can I do? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update problem
Blake Schroeder wrote: The form that is being submitted can only be a POST or a GET not both example: form method=post action=foo.php input type=text name=foo1 input type=submit /form How can you do both? form method=post action=foo.php?id=1 input type=text name=foo1 input type=submit /form Hope that answers your question ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update problem
Put a hidden field in your form named id. -Blake Blake Schroeder wrote: The form that is being submitted can only be a POST or a GET not both example: form method=post action=foo.php input type=text name=foo1 input type=submit /form How can you do both? -Blake Maldiv wrote: Hello, I have a php update form which use $_POST and $_GET too. I call the update like this update.php?id=1 And after the user submit the form with new data I use command like this: UPDATE table SET id=$_POST['id'] WHERE $_GET['id']='1'; This code works on localhost with Apache 2, Win XP, and Php 4.3.5 but it doesn't works on my real server(Php 4.3.3, Linux, Apache 1.??) I debuged it and I realised that on localhost I have the correct value in the $_GET but in remote $_GET is empty. What can I do? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update problem
That will work, but the below is really supposed to work. I use it in my apps. Blake Schroeder wrote: Put a hidden field in your form named id. -Blake Mattias Thorslund wrote: Probably with form method=post action=foo.php?id=123 Blake Schroeder wrote: The form that is being submitted can only be a POST or a GET not both example: form method=post action=foo.php input type=text name=foo1 input type=submit /form How can you do both? -Blake Maldiv wrote: Hello, I have a php update form which use $_POST and $_GET too. I call the update like this update.php?id=1 And after the user submit the form with new data I use command like this: UPDATE table SET id=$_POST['id'] WHERE $_GET['id']='1'; This code works on localhost with Apache 2, Win XP, and Php 4.3.5 but it doesn't works on my real server(Php 4.3.3, Linux, Apache 1.??) I debuged it and I realised that on localhost I have the correct value in the $_GET but in remote $_GET is empty. What can I do? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update problem
To reply to the original post (sorry for the confusion): Maldiv wrote: Hello, I have a php update form which use $_POST and $_GET too. I call the update like this update.php?id=1 And after the user submit the form with new data I use command like this: UPDATE table SET id=$_POST['id'] WHERE $_GET['id']='1'; This code works on localhost with Apache 2, Win XP, and Php 4.3.5 but it doesn't works on my real server(Php 4.3.3, Linux, Apache 1.??) I debuged it and I realised that on localhost I have the correct value in the $_GET but in remote $_GET is empty. What can I do? Thanks! I wonder if track_vars is off in php.ini? But then, I suppose$_POST['id'] would be empty, too. Anyway, I'd suggest using different names for the GET and POST variables. For instance new_ID for the POST variable. /Mattias /Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] update mysql using radio button
[snip] i'm having a problem getting an UPDATE to work with radio buttons and i'm not sure where it's gone wrong. the initial values are being grabbed properly, but unfortunately they don't want to get updated. the regular text form values update just fine. would appreciate some help. the html: input type=hidden name=id value=?php echo $id ? club member?br No: input type=radio name=club_member ?php if($row-club_member == 'N'){echo 'CHECKED';}?br Yes: input type=radio name=club_member ?php if($row-club_member == 'Y'){echo 'CHECKED';}? [/snip] You have to create a value for the box...or check for ON function radioBox($radioBoxState){ /* ** this function will get the tail value of the checked radio button ** and return the appropriate value for use by the database, either a ** 'y' or 'n' */ if(TRUE == preg_match('/Yes/', $radioBoxState)){ $radioBoxState = y; } elseif(TRUE == preg_match('/No/', $radioBoxState)){ $radioBoxState = n; } return $radioBoxState; } function checkBox($checkBoxState){ /* ** this is a function that will turn an 'on' checkbox into a 'y' for the database ** if it is not 'on' an 'n' will be returned */ if(on == $checkBoxState){ $checkBoxData = y; } else { $checkBoxData = n; } return $checkBoxData; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql using radio button
I think you need Values for the radio buttons. input type=radio name=club_member Value=N ?php if($row-club_member ='N'){echo 'CHECKED';}? hello all - i'm having a problem getting an UPDATE to work with radio buttons and i'm not sure where it's gone wrong. the initial values are being grabbed properly, but unfortunately they don't want to get updated. the regular text form values update just fine. would appreciate some help. the html: input type=hidden name=id value=?php echo $id ? club member?br No: input type=radio name=club_member ?php if($row-club_member ='N'){echo 'CHECKED';}?br Yes: input type=radio name=club_member ?php if($row-club_member == 'Y'){echo 'CHECKED';}? the query to update: $query = UPDATE outdoor SET name='$name', email='$email', zip='$zip', club_member='$club_member' WHERE id='$id'; $result = mysql_query($query) or die (Error in query: $query. . mysql_error()); [trying to keep the code paste to what i think is important, let me know if more is needed for info.] thanks! m. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] update mysql using radio button
how embarrassing. :] yes, of course that would be the problem. just to note, i'm enjoying learning php/mysql and appreciate the help from this list. it's a great community and the good will makes it a great place to ask the sometimes really stupid questions. best, m. -Original Message- From: Daniel Clark [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 01, 2004 1:14 PM To: Matt Newell Cc: [EMAIL PROTECTED] Subject: Re: [PHP] update mysql using radio button I think you need Values for the radio buttons. input type=radio name=club_member Value=N ?php if($row-club_member ='N'){echo 'CHECKED';}? hello all - i'm having a problem getting an UPDATE to work with radio buttons and i'm not sure where it's gone wrong. the initial values are being grabbed properly, but unfortunately they don't want to get updated. the regular text form values update just fine. would appreciate some help. the html: input type=hidden name=id value=?php echo $id ? club member?br No: input type=radio name=club_member ?php if($row-club_member ='N'){echo 'CHECKED';}?br Yes: input type=radio name=club_member ?php if($row-club_member == 'Y'){echo 'CHECKED';}? the query to update: $query = UPDATE outdoor SET name='$name', email='$email', zip='$zip', club_member='$club_member' WHERE id='$id'; $result = mysql_query($query) or die (Error in query: $query. . mysql_error()); [trying to keep the code paste to what i think is important, let me know if more is needed for info.] thanks! m. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql using radio button
From: Daniel Clark [EMAIL PROTECTED] input type=radio name=club_member Value=N ?php if($row-club_member ='N'){echo 'CHECKED';}? =='N', you mean. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql using radio button
Right. (oops) From: Daniel Clark [EMAIL PROTECTED] input type=radio name=club_member Value=N ?php if($row-club_member ='N'){echo 'CHECKED';}? =='N', you mean. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Update Multiple Records From Form
On 28 May 2004 04:47, Albert Padley wrote: I feel I'm so close. I have a form with multiple database records with a checkbox to indicate which records to update set up like so: $name = ed[ . $row['id'] . ]; input type=\checkbox\ name=\ . $name . \ value=\Y\ Each text input is set up like so: input type=\text\ name=\fname[]\ value=\ . $row['fname'] . \ On the processing page I am doing this: foreach($ed as $id=$val){ $query = UPDATE ref_events_reg SETfname = '$fname' WHERE id = '{$id}'; I am looping through the correct records, but every field is being updated to Array. What tweak do I need to make? I'd make two tweaks, actually. First and most obviously, you're not selecting *which* fname field to pass to your update query, so this needs to be: $query = UPDATE ref_events_reg SET fname = '{$fname[$id]}' WHERE id = '{$id}'; (By putting just $fname there, you are telling PHP to insert the string representation of the whole array -- and the string representation of any array is, er, exactly Array! ;) This change may give you a clue to my other tweak -- I'd explicitly set the indexes of all the fname[] fields to be sure they sync correctly to the related check box, thus: input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\ input type=\text\ name=\fname[{$row['id']}]\ value=\{$row['fname']}\ Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update Multiple Records From Form
On May 28, 2004, at 3:50 AM, Ford, Mike [LSS] wrote: On 28 May 2004 04:47, Albert Padley wrote: I feel I'm so close. I have a form with multiple database records with a checkbox to indicate which records to update set up like so: $name = ed[ . $row['id'] . ]; input type=\checkbox\ name=\ . $name . \ value=\Y\ Each text input is set up like so: input type=\text\ name=\fname[]\ value=\ . $row['fname'] . \ On the processing page I am doing this: foreach($ed as $id=$val){ $query = UPDATE ref_events_reg SETfname = '$fname' WHERE id = '{$id}'; I am looping through the correct records, but every field is being updated to Array. What tweak do I need to make? I'd make two tweaks, actually. First and most obviously, you're not selecting *which* fname field to pass to your update query, so this needs to be: $query = UPDATE ref_events_reg SET fname = '{$fname[$id]}' WHERE id = '{$id}'; (By putting just $fname there, you are telling PHP to insert the string representation of the whole array -- and the string representation of any array is, er, exactly Array! ;) This change may give you a clue to my other tweak -- I'd explicitly set the indexes of all the fname[] fields to be sure they sync correctly to the related check box, thus: input type=\checkbox\ name=\ed[{$row['id']}]\ value=\Y\ input type=\text\ name=\fname[{$row['id']}]\ value=\{$row['fname']}\ Cheers! Mike Mike, Thanks for the tweaks. That solved the problem. I had actually tried something like that, but obviously didn't have all the parts working together at the same time. Thanks again. Albert Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
Daniel Clark [EMAIL PROTECTED] wrote on 04/06/2004 03:27:34 PM: I think you need a WHERE clause for the UPDATE, otherwise it will update ALL the records. e.g. WHERE OwnerName='$result' Then perhaps a redirect to another page. Thanks for the reminder. I set that, and found the problem that caused the page to not load at all - no closing double-quote on the update statement. Now the page loads properly but when I press the submit button nothing happens, it's a dead button. -- if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address',OwnerCity='$city',OwnerState='$state',OwnerZip='$zip',OwnerCountry='$country',DateInstalled='$DateInstalled',DealerName='$Dealer',DealerStreet='$DealerAddress',DealerCity='$DealerCity',DealerState='$DealerState',DealerZip='$DealerZip',DealerCountry='$DealerCountry',Model='$Parts',SN='$PartsSN',VesselType='$vesseltype',VesselLength='$length',InstalledOn='$construction',VesselTypeOther='$vesseltypeother') where OwnerName = $OwnerName; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? ... lots of code ... pcenterinput type=submit name=submit value=Update Data/center/p ... more code ... /table ? endif; ? /body /html - I don't see any reason for the submit button to not work at all. What should I look for now? Thanks for the help, Chip I probably need to use if(isset($submit)): and an update statement, but my attempt just causes the web page to display completely blank. This is what I tried - if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address', OwnerCity='$city',OwnerState='$state',OwnerZip='$zip', OwnerCountry='$country',DateInstalled='$DateInstalled', DealerName='$Dealer',DealerStreet='$DealerAddress', DealerCity='$DealerCity',DealerState='$DealerState', DealerZip='$DealerZip',DealerCountry='$DealerCountry', Model='$Parts',SN='$PartsSN',VesselType='$vesseltype', VesselLength='$length',InstalledOn='$construction', VesselTypeOther='$vesseltypeother') ; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
For the submit button to work it has to be in a form. FORM ACTION=blah_blah.php METHOD=post INPUT TYPE=submit /FORM Hope this helps. Daniel Clark pcenterinput type=submit name=submit value=Update Data/center/p ... more code ... /table ? endif; ? /body /html - I don't see any reason for the submit button to not work at all. What should I look for now? Thanks for the help, Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
Daniel Clark [EMAIL PROTECTED] wrote on 04/07/2004 10:17:36 AM: For the submit button to work it has to be in a form. FORM ACTION=blah_blah.php METHOD=post INPUT TYPE=submit /FORM Hope this helps. Daniel Clark Of course, I didn't notice I left that line out of my code, although I did remember to put in the closing form tag. But, unfortumately, the update is not executed. The form button works, and it appears to do what it should, but the data is not changed. I changed the form method to get so I could see what is being passed and everything there is fine, but at the end of the url I see this- url...stuff...submit=Update+Data Is this correct? What else can I do to see what was passed to the database (if anything)? -- Chip pcenterinput type=submit name=submit value=Update Data/center/p ... more code ... /table ? endif; ? /body /html - I don't see any reason for the submit button to not work at all. What should I look for now? Thanks for the help, Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
Something I like to do during troubleshooting is to have the page display the SQL statement I'm processing. Something like: print sql_query ; That was I can verify all the parameters are correct. Do you have autocommit ON? Or need to pass a commit statement? Daniel Clark Of course, I didn't notice I left that line out of my code, although I did remember to put in the closing form tag. But, unfortumately, the update is not executed. The form button works, and it appears to do what it should, but the data is not changed. I changed the form method to get so I could see what is being passed and everything there is fine, but at the end of the url I see this- url...stuff...submit=Update+Data Is this correct? What else can I do to see what was passed to the database (if anything)? -- Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
I think you need a WHERE clause for the UPDATE, otherwise it will update ALL the records. e.g. WHERE OwnerName='$result' Then perhaps a redirect to another page. I probably need to use if(isset($submit)): and an update statement, but my attempt just causes the web page to display completely blank. This is what I tried - if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address',OwnerCity='$city',OwnerState='$state',OwnerZip='$zip',OwnerCountry='$country',DateInstalled='$DateInstalled',DealerName='$Dealer',DealerStreet='$DealerAddress',DealerCity='$DealerCity',DealerState='$DealerState',DealerZip='$DealerZip',DealerCountry='$DealerCountry',Model='$Parts',SN='$PartsSN',VesselType='$vesseltype',VesselLength='$length',InstalledOn='$construction',VesselTypeOther='$vesseltypeother') ; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
Chip Wiegand wrote: I have an existing web page that pulls some data and displays it in form input fields. I would like to add the ability to edit those fields and submit the changes to the server, but have been unsuccessful. What bit of code do I need to add to the existing code? This is the existing code to display the info -- $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); I probably need to use if(isset($submit)): and an update statement, but my attempt just causes the web page to display completely blank. This is what I tried - if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address',OwnerCity='$city',OwnerState='$state',OwnerZip='$zip',OwnerCountry='$country',DateInstalled='$DateInstalled',DealerName='$Dealer',DealerStreet='$DealerAddress',DealerCity='$DealerCity',DealerState='$DealerState',DealerZip='$DealerZip',DealerCountry='$DealerCountry',Model='$Parts',SN='$PartsSN',VesselType='$vesseltype',VesselLength='$length',InstalledOn='$construction',VesselTypeOther='$vesseltypeother') ; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? What am I doing wrong? Thanks, -- Chip register_globals is probably off echo out the query to see if your variables are populated. -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update issue - more then likely simple problem
On Thu, Dec 18, 2003 at 01:39:57PM +1100, Eric Holmstrom wrote: What im trying to do is read the information from a field in a table called PARTNO. Then add RU to the front of whatever is in the PARTNO field. So far i have this. //connect details rarara //query $query= SELECT PARTNO FROM russell2 ; Didn't you say the table was called PARTNO, not russell2? // make a query to get old stuff from DB col $oldstuff = mysql_query($query, $conn) or die(mysql_error()); while ($new = mysql_fetch_array($oldstuff)){ $final = $new['PARTNO']; //new infomation i want to add infront of PARTNO data $newstuff = 'RU'; //Combining the two resluts together $results = $newstuff.$final; // just use this to check it was going through properly print_r($resultsbr); } The problem i have to get it to update. If i add this (see below) inside the while statement it continually loops, and outside it doesnt work. $update = UPDATE rocket SET PARTNO = '$results''; mysql_query($update); I know the answer is simple but i seem to be stuck on it. I don't think you can just update a row that you just fetched within the same query. If you do this in PHP, you should split the update into a separate loop. Of course, it would be faster and more efficient to have MySQL do it for you: UPDATE rocket SET PARTNO = CONCAT('RU',PARTNO) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update issue - more then likely simple problem
Thankyou i did not know that command existed! so simple cheers Eugene Lee [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, Dec 18, 2003 at 01:39:57PM +1100, Eric Holmstrom wrote: What im trying to do is read the information from a field in a table called PARTNO. Then add RU to the front of whatever is in the PARTNO field. So far i have this. //connect details rarara //query $query= SELECT PARTNO FROM russell2 ; Didn't you say the table was called PARTNO, not russell2? // make a query to get old stuff from DB col $oldstuff = mysql_query($query, $conn) or die(mysql_error()); while ($new = mysql_fetch_array($oldstuff)){ $final = $new['PARTNO']; //new infomation i want to add infront of PARTNO data $newstuff = 'RU'; //Combining the two resluts together $results = $newstuff.$final; // just use this to check it was going through properly print_r($resultsbr); } The problem i have to get it to update. If i add this (see below) inside the while statement it continually loops, and outside it doesnt work. $update = UPDATE rocket SET PARTNO = '$results''; mysql_query($update); I know the answer is simple but i seem to be stuck on it. I don't think you can just update a row that you just fetched within the same query. If you do this in PHP, you should split the update into a separate loop. Of course, it would be faster and more efficient to have MySQL do it for you: UPDATE rocket SET PARTNO = CONCAT('RU',PARTNO) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update password cookie
--- John Kaspar [EMAIL PROTECTED] wrote: My question is - how do I update the password cookie without having to ask whether or not they want to remember it again? How can I find out when the current cookie expires? First, I hope you're not storing a password in a cookie, since it sounds like you are. To address your question, you can't. A Web client only returns a cookie name and value in the Cookie header, so PHP does not have access to any other information except that. My advice is to examine how other sites do this sort of thing. For example, go to Yahoo!, log into one of their services, and check the box that says remember me. There will be a cookie with your username that expires sometime in the future (one year maybe?). They keep up with everything else on the server. Basically, cookie attributes are restrictive. You cannot make them less restrictive with your server-side code, but you can make them more restrictive with your server-side code. For example, if a cookie is set to expire in 24 hours, and someone goes to your site 48 hours later, that cookie won't be there. If, however, the cookie is set to expire in 96 hours, and someone goes to your site in 48 hours, you can decide whether you want to use the information in the cookie or consider it to be expired. Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update password cookie
I'm just storing its hash. Then comparing it to the database hash. Is that bad? Is there a good write-up somewhere discussing authentication techniques that you could recommend? Yahoo makes you reenter your password every time you reopen your browser. I'll check other sites though. Thanks for the advice. On 9/18/2003 5:37 PM, Chris Shiflett wrote: First, I hope you're not storing a password in a cookie, since it sounds like you are. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] update password cookie
John Kaspar mailto:[EMAIL PROTECTED] on Thursday, September 18, 2003 4:05 PM said: Yahoo makes you reenter your password every time you reopen your browser. I'll check other sites though. Thanks for the advice. As it should. You don't want to store password information in a cookie, that's why yahoo requires you to reenter each time. The only thing a site should keep in a cookie regarding username and password is the username. yahoo (as well as many other sites) offer the option of saving the username in a cookie so that when you get back to the site your username is automatically filled in. it probably helps relieve the i forgot my username emails. chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] update password cookie
John Kaspar mailto:[EMAIL PROTECTED] on Thursday, September 18, 2003 4:05 PM said: I'm just storing its hash. Then comparing it to the database hash. Is that bad? Is there a good write-up somewhere discussing authentication techniques that you could recommend? Oh I should respond to this as well. This is just a little better than storing a plain text password. Reason being that the next person that uses that computer can read the cookie and steal the hash. They would then be able to reverse* it and get the password so they could log in like a normal user. Chris. * By reverse I don't mean decrypt or unencrypt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update password cookie
--- John Kaspar [EMAIL PROTECTED] wrote: I'm just storing its hash. Then comparing it to the database hash. Is that bad? Yes, but the risk is not so much that the user's password is in danger of being acquired, but rather than this step is not necessary to impersonate the user. This hash of the password is an authentication credential, and you're using it for identification. This is not necessary. Is there a good write-up somewhere discussing authentication techniques that you could recommend? Again, I think the important point here is to distinguish between authentication and identification. You only have to authenticate a user once. After that, your focus is on identifying the user. Identification is not trivial, since you want to protect against impersonation (session hijacking), but passing authentication credentials around on the Internet more than necessary is not a good idea. As for a description somewhere, I just put up a page describing cookies: http://shiflett.org/books/http-developers-handbook/chapters/11 The figures aren't up yet, but I think they're unecessary for your particular question. Yahoo makes you reenter your password every time you reopen your browser. Right. Yahoo! remembers you, not your authentication information. It enforces a session timeout of some sort (user configurable in many cases, up to a certain maximum length) for the session itself, but the cookie with your username lasts a very long time. When your session expires, you only have to enter your password. Still, because a username can be considered half of the authentication credentials (even though it's the easiest to guess), users are only given this as an option. Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update question
At 21:12 02.06.2003, Matt Hedges said: [snip] Hello, I am new to PHP and would greatly appreciate any help. I am building a webpage for my sister's sorority- http://olemissddd.com. I have built a page that allows them to update the officers each year- http://hedges.org/ddd/olemiss/updateofficers.php and then view those officers- http://hedges.org/ddd/olemiss/officers.php . However, what I want to be able to do that I can't figure out is for when they leave one of the fields blank it doesn't change anything. As it is now, when they change one of the fields and leave the others blank it will overwrite the names it had for them with blank spaces. I want to be able to do this so for example if they mistype someone's name, etc. So somehow I need to be able to tell it that when the user leaves the field blank, not to change that field in MySQL. [snip] Try something like if (!empty($_REQUEST['fieldname'])) dbupdate('fieldname'); http://www.php.net/manual/en/function.empty.php -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update question [T20030602013J]
At 21:41 02.06.2003, you said: [snip] This is an automatic reply to acknowledge that your message has been received. PLEASE DO NOT REPLY TO THIS MESSAGE. -- Dear [EMAIL PROTECTED], Thank you for submitting your question to our Technical Support Department. We received it on 6/2/2003 at 12:41:25 PM. Your tracking number for this message is: T20030602013J. This message and tracking number are your assurance that we have received your message and will respond to it as quickly as possible. At BONZI Software we attempt to answer all of the questions we get on a first-come, first-served basis, as quickly as possible. On occasion we receive a large volume of e-mail that prevents us from answering your message as quickly as we would like. Please be assured that we have your message and will respond to it as quickly as we can. If your question to us is of a support nature, you can visit http://www.bonzi.com/support.htm to try and find an answer to your question in our online support center. This will often be quicker than we can reply to your message by hand, so we encourage you to try it out. Sincerely, Customer Support BONZI Software HTTP://www.bonzi.com [snip] Dear [EMAIL PROTECTED], I _do_ dare and reply., and I hope a lot of the listmembers that have been spammed by you will do the same. I never sent a message to you, nor am I interested in any way in your services. Please refrain from hooking into mailing lists and bombarding the listmembers with absolutely unneccessary, unsolicited and impolite spams camouflaged as auto-reply. Thank you for consideration. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update question [T20030602013J]
Whenever I sign up to a new news service/website or the like, I give them their own alias at my domain, so i can see how my email address is used ;o) Hence the [EMAIL PROTECTED] Hate spammers. No need. Bix. Ernest E Vogelsinger [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] At 21:41 02.06.2003, you said: [snip] This is an automatic reply to acknowledge that your message has been received. PLEASE DO NOT REPLY TO THIS MESSAGE. -- Dear [EMAIL PROTECTED], Thank you for submitting your question to our Technical Support Department. We received it on 6/2/2003 at 12:41:25 PM. Your tracking number for this message is: T20030602013J. This message and tracking number are your assurance that we have received your message and will respond to it as quickly as possible. At BONZI Software we attempt to answer all of the questions we get on a first-come, first-served basis, as quickly as possible. On occasion we receive a large volume of e-mail that prevents us from answering your message as quickly as we would like. Please be assured that we have your message and will respond to it as quickly as we can. If your question to us is of a support nature, you can visit http://www.bonzi.com/support.htm to try and find an answer to your question in our online support center. This will often be quicker than we can reply to your message by hand, so we encourage you to try it out. Sincerely, Customer Support BONZI Software HTTP://www.bonzi.com [snip] Dear [EMAIL PROTECTED], I _do_ dare and reply., and I hope a lot of the listmembers that have been spammed by you will do the same. I never sent a message to you, nor am I interested in any way in your services. Please refrain from hooking into mailing lists and bombarding the listmembers with absolutely unneccessary, unsolicited and impolite spams camouflaged as auto-reply. Thank you for consideration. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Update to DB
[snip] I was just wondering how to update data to database from html text field. Anyone know what is the proper way to do this? [/snip] The action for your form can contain an SQL UPDATE statement where the values in the database are updated with the values in the form. Fairly simple. Here is an example from some of my code on a project... //update tables for each set $qup = UPDATE tblClassOthers ; $qup .= SET BilledFlag = ' . date(Y-m-d) . ', ; $qup .= CycleFlag = ' . $emicycle . ' ; $qup .= WHERE RecordDate = ' . $emidate . ' ; $qup .= AND RecordID = '010101' ; $qup .= AND BilledFlag = '' ; if(!($dbup = mysql_query($qup, $dbconnect))){ print(MySQL reports: . mysql_error() . \n); exit(); } HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update to DB
Kalle Saarinen wrote: Hello, I was just wondering how to update data to database from html text field. I have a form that retrieves data from dbase and put's values into text field in a web page. I want to be able to modify data and then save it dbase by hitting save button (also form object). ie. $sql=SELECT col1 FROM table WHERE id = 1; $result=mysql_query($sql); $num = mysql_num_rows($result); $row = mysql_fetch_array($result); $var = $row[col1]; echo form name=\form1\ method=\post\ action=\\; echo input name=\name\ type=\text\ id=\name\ value=\$var1\ size=\30\ maxlength=\30\; echo input name=\save\ type=\submit\ id=\save\ value=\save\; Anyone know what is the proper way to do this? -Kalle You need to capture the values passed by the form in the script referenced in the form action attribute, using the relevant superglobal referenced in the form method attribute (e.g. $_GET or $_POST). Using your example, you would access the name form element like so: $_POST['name'] Then you should use this variable in an UPDATE or INSERT statement and send that to your database server, e.g.: mysql_query(UPDATE table SET col1 = . $_POST['name'] . WHERE id = . $_POST['id'] . LIMIT 1); I would suggest reading the PHP manual a little more carefully, in particular those sections regarding variable and form handling, as well as the section on MySQL. Regards, David -- David Grant Web Developer [EMAIL PROTECTED] http://www.wiredmedia.co.uk Tel: 0117 930 4365, Fax: 0870 169 7625 Wired Media Ltd Registered Office: 43 Royal Park, Bristol, BS8 3AN Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD Company registration number: 4016744 ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update Status Question
Hi, Thursday, March 13, 2003, 6:10:29 AM, you wrote: MW Hello: MW I have this line: MW $sql = Update Members Set Active='Y' where Username = '$_GET[UN]' And MW ActiveCode = '$_GET[ID]'; MW Is there a php function that will return true or false or something when MW this is processed. I.E. if the Where clause fails it would report back MW fail? Or do I first need to check the status with a select? MW Thank you, MW Mike Walth MW CinoFusion If using mysql you can use if(mysql_affected_rows()){ echo 'Success'; }else{ echo 'Oops'; } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update MD5 Field
Run the following SQL query: update TABLE set code = md5(concat(name,email)) Dani Matielo wrote: Hello, everybody my problem is the following: I just imported a csv file to a MySQL database that contains name and email fields. It has about 9k lines on it and I need a new field that orinally didn't exist called code thats suposed to be MD5(name.email) I know how to do this for new data, but I don't know how to update all the old ones I already have there. Thank you in advance, Daniela -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update query not working
print INPUT TYPE=\Submit\ NAME=\Submit\ Value=\Update\/td; print /form; if ($_POST['Update']) { print updated!!; } I do not see the statement updated!!! printed, but I cannot see anything wrong with my syntax. Any help would be appreciated. You are looking for a value, where the array is of the form $_POST['form_element_NAME'='form_element_VALUE' So try looking for if ($_POST['Submit']=='Update') { } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update query not working
On Monday 24 February 2003 06:56, Peter Gumbrell wrote: I wonder if anyone can see why the following code is not working. this is taken from a larger functions, the rest of which seems to be working well: print INPUT TYPE=\Submit\ NAME=\Submit\ Value=\Update\/td; print td/tdtd/td/tr; print /table; print /form; if ($_POST['Update']) [snip] print_r($_POST) to see what it contains. It probably contains an entry named 'Submit' as that is what you have named your submit button. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Trying to be happy is like trying to build a machine for which the only specification is that it should run noiselessly. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update to table errors/strange things happen
//connect to server and database ?php include(conf.inc);//config file for db, username... mysql_connect($host, $mysqluser, $mysqlpwd)||die(cant find $host or username/pwd wrong); mysql_select_db($db)||die($db doesnt exist or has a problem...); //following code goes for each combobox to use //if you have a different field for each //combobox..otherwise //put this at top of file $query=mysql_query(select company from members); ? //start combo box select name=name option value=select a member to editbr //code to populate combobox from db ?php while($edit=mysql_fetch_array($query)){ //use your variables instead of mine make sure to use the //\ before and after all var names echo option value=\$edit[Company]\\$edit[Company]br; } ? /select //rest of code for page here... not that hard probably about 4 lines of code to make the box and put db stuff in it... still need to figure out why my update statement updates all records if someone retypes the same value in the form though - Original Message - From: Guru Geek [EMAIL PROTECTED] To: Sunfire [EMAIL PROTECTED] Sent: Friday, February 07, 2003 12:08 PM Subject: Re: [PHP] update to table errors/strange things happen Could I just see the section of code that populates the combo box with database info? I'm trying to do that exact same thing, but can't figure out the code Thanks, Roger Sunfire wrote: i have a combo box on a web page that gets all the companies names from a mysql table and puts them in the combobox.. when someone picks a name and hits an edit button it takes them to a form where all the values in the table fields for that record are shown as default values for the form fields. my problem is when someone changes a value say the city or state (but it happens with any of the fields) and if for some reason they change it to the same value that was already in the record then all of the records get changed and updated to show that every records have the same values for all fields... does anybody know why that is and possible how to fix that problem so only that record gets changed? my source is rather huge in size and since i cant find the place where the problem is coming from it would be hard to post all the source here.. can anybody help? my update statement has all 16 fields in it because i dont know if you can do conditional updates with variables and if you can how to do that... --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update row problems
your query needs to be inside the foreach loop so that it runs for every item, at the moment it just runs after you've scanned through all the items so just does the last one. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 11:46 AM Subject: [PHP] Update row problems Hi all, I've been playing with this for a few hours now (over the course of a couple of days) and it's getting frustrating! All I want to do is to be able to make one row in the database set the order that my categories appear on my website. Now I can do this fine simply by using ORDER_BY but I want to have my users be able to update the order through an admin page like so: - Catid | catname | catdesc | catorder | 1name desc 1 2name desc 2 3name desc 3 4name desc 4 __ Basically I have a form which takes data from the table above and displays catname (just echoed) and catorder in a text form field. When I submit the form I want to update catorder with whatever number the user puts in the field. Currently my code updates only one of the category order numbers. So my form code: form action=eshop_processcatorder.php method=post /td/tr ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder[{$array[catid]}]' value='{$array[catorder]}'; echo /span/td/tr; } ? trtdbr input type=submit name=Submit value=Submit class=nappi /form That does everything I need it to do. However what am I doing wrong when I try to process it using this code? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; } $result = mysql_query($query) or die(Query failure: .mysql_error()); if (!$result) { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'Could not change details: please a href='mailto:[EMAIL PROTECTED]'click here/a to email the administratorbrbr/span; echo /td; echo /tr; echo /table; } else { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'The category page has had the order in which categories appear changed.brbr/span; echo /td; echo /tr; echo /table; } Any help appraciated. Kind regards, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Update row problems
I'm processing on a different page so what would I use instead of $_POST? print_r($_POST) Didn't display anything or diagnose anything. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:57 To: Steve Jackson Subject: Re: [PHP] Update row problems sounds like $_POST[catorder] isn't an array - if you're posting to the same page you need to wrap the processing in something to test if the form has been posted (e.g. is_array($_POST[catorder])), or maybe you're using an older versionof PHP where $_POST isn't available -try using print_r($_POST) for diagnostics. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: 'Tim Ward' [EMAIL PROTECTED] Sent: Monday, January 27, 2003 12:52 PM Subject: RE: [PHP] Update row problems Ok, I put the query in the loop and now I get this error? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; $result = mysql_query($query) or die(Query failure: .mysql_error()); } Warning: Invalid argument supplied for foreach() in /home/stephenj/public_html/viola/eadmin/eshop_processcatorder.php on line 27 Is it a $_POST problem? Using PHP 4.06 Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:11 To: PHP General; Steve Jackson Subject: Re: [PHP] Update row problems your query needs to be inside the foreach loop so that it runs for every item, at the moment it just runs after you've scanned through all the items so just does the last one. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 11:46 AM Subject: [PHP] Update row problems Hi all, I've been playing with this for a few hours now (over the course of a couple of days) and it's getting frustrating! All I want to do is to be able to make one row in the database set the order that my categories appear on my website. Now I can do this fine simply by using ORDER_BY but I want to have my users be able to update the order through an admin page like so: - Catid | catname | catdesc | catorder | 1name desc 1 2name desc 2 3name desc 3 4name desc 4 __ Basically I have a form which takes data from the table above and displays catname (just echoed) and catorder in a text form field. When I submit the form I want to update catorder with whatever number the user puts in the field. Currently my code updates only one of the category order numbers. So my form code: form action=eshop_processcatorder.php method=post /td/tr ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder[{$array[catid]}]' value='{$array[catorder]}'; echo /span/td/tr; } ? trtdbr input type=submit name=Submit value=Submit class=nappi /form That does everything I need it to do. However what am I doing wrong when I try to process it using this code? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; } $result = mysql_query($query) or die(Query failure: .mysql_error()); if (!$result) { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'Could not change details: please a href='mailto:[EMAIL PROTECTED]'click here/a to email the administratorbrbr/span; echo /td; echo /tr; echo /table; } else { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'The category page has had the order in which categories appear changed.brbr/span; echo /td; echo /tr; echo /table; } Any help appraciated
Re: [PHP] Update row problems
what version of PHP? try $HTTP_POST_VARS instead. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 1:14 PM Subject: RE: [PHP] Update row problems I'm processing on a different page so what would I use instead of $_POST? print_r($_POST) Didn't display anything or diagnose anything. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:57 To: Steve Jackson Subject: Re: [PHP] Update row problems sounds like $_POST[catorder] isn't an array - if you're posting to the same page you need to wrap the processing in something to test if the form has been posted (e.g. is_array($_POST[catorder])), or maybe you're using an older versionof PHP where $_POST isn't available -try using print_r($_POST) for diagnostics. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: 'Tim Ward' [EMAIL PROTECTED] Sent: Monday, January 27, 2003 12:52 PM Subject: RE: [PHP] Update row problems Ok, I put the query in the loop and now I get this error? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; $result = mysql_query($query) or die(Query failure: .mysql_error()); } Warning: Invalid argument supplied for foreach() in /home/stephenj/public_html/viola/eadmin/eshop_processcatorder.php on line 27 Is it a $_POST problem? Using PHP 4.06 Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:11 To: PHP General; Steve Jackson Subject: Re: [PHP] Update row problems your query needs to be inside the foreach loop so that it runs for every item, at the moment it just runs after you've scanned through all the items so just does the last one. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 11:46 AM Subject: [PHP] Update row problems Hi all, I've been playing with this for a few hours now (over the course of a couple of days) and it's getting frustrating! All I want to do is to be able to make one row in the database set the order that my categories appear on my website. Now I can do this fine simply by using ORDER_BY but I want to have my users be able to update the order through an admin page like so: - Catid | catname | catdesc | catorder | 1name desc 1 2name desc 2 3name desc 3 4name desc 4 __ Basically I have a form which takes data from the table above and displays catname (just echoed) and catorder in a text form field. When I submit the form I want to update catorder with whatever number the user puts in the field. Currently my code updates only one of the category order numbers. So my form code: form action=eshop_processcatorder.php method=post /td/tr ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder[{$array[catid]}]' value='{$array[catorder]}'; echo /span/td/tr; } ? trtdbr input type=submit name=Submit value=Submit class=nappi /form That does everything I need it to do. However what am I doing wrong when I try to process it using this code? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; } $result = mysql_query($query) or die(Query failure: .mysql_error()); if (!$result) { echo table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#629D39'; echo trtdimg src='images/admin_orders_administrate.gif'/td/tr; echo trtdnbsp;/td/tr; echo trtdspan class='adminisoleipa'Could not change details: please a href='mailto:[EMAIL PROTECTED]'click here/a to email the administratorbrbr/span; echo /td; echo
RE: [PHP] Update row problems
Thanks. That was the problem. Im using 4.0.6 so it's a bit out of date. Cheers, Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 15:32 To: PHP General; Steve Jackson Subject: Re: [PHP] Update row problems what version of PHP? try $HTTP_POST_VARS instead. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 1:14 PM Subject: RE: [PHP] Update row problems I'm processing on a different page so what would I use instead of $_POST? print_r($_POST) Didn't display anything or diagnose anything. Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:57 To: Steve Jackson Subject: Re: [PHP] Update row problems sounds like $_POST[catorder] isn't an array - if you're posting to the same page you need to wrap the processing in something to test if the form has been posted (e.g. is_array($_POST[catorder])), or maybe you're using an older versionof PHP where $_POST isn't available -try using print_r($_POST) for diagnostics. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: 'Tim Ward' [EMAIL PROTECTED] Sent: Monday, January 27, 2003 12:52 PM Subject: RE: [PHP] Update row problems Ok, I put the query in the loop and now I get this error? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where catid=$catid; $result = mysql_query($query) or die(Query failure: .mysql_error()); } Warning: Invalid argument supplied for foreach() in /home/stephenj/public_html/viola/eadmin/eshop_processcatorder.php on line 27 Is it a $_POST problem? Using PHP 4.06 Steve Jackson Web Developer Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Tim Ward [mailto:[EMAIL PROTECTED]] Sent: 27. tammikuuta 2003 14:11 To: PHP General; Steve Jackson Subject: Re: [PHP] Update row problems your query needs to be inside the foreach loop so that it runs for every item, at the moment it just runs after you've scanned through all the items so just does the last one. Tim Ward http://www.chessish.com mailto:[EMAIL PROTECTED] - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, January 27, 2003 11:46 AM Subject: [PHP] Update row problems Hi all, I've been playing with this for a few hours now (over the course of a couple of days) and it's getting frustrating! All I want to do is to be able to make one row in the database set the order that my categories appear on my website. Now I can do this fine simply by using ORDER_BY but I want to have my users be able to update the order through an admin page like so: - Catid | catname | catdesc | catorder | 1name desc 1 2name desc 2 3name desc 3 4name desc 4 __ Basically I have a form which takes data from the table above and displays catname (just echoed) and catorder in a text form field. When I submit the form I want to update catorder with whatever number the user puts in the field. Currently my code updates only one of the category order numbers. So my form code: form action=eshop_processcatorder.php method=post /td/tr ? while ($array = mysql_fetch_array($mysql)) { echo trtd width='150'span class='adminisoleipa'; echo {$array[catname]}; echo /tdtdinput type='text' size='2' name='catorder[{$array[catid]}]' value='{$array[catorder]}'; echo /span/td/tr; } ? trtdbr input type=submit name=Submit value=Submit class=nappi /form That does everything I need it to do. However what am I doing wrong when I try to process it using this code? foreach($_POST[catorder] as $catid = $catorder) { $query = update categories set catorder=$catorder where
Re: [PHP] update more same fields at the same time
At 10:07 15-1-03, you wrote: I have table with six records in it. I can use while to display them all, but in form. Is there any way I can edit all six records, and update them all with one submit. One of the many ways to do it: When writing the form, number the fieldnames with the ID's of the items. Separate name and ID with a clear character like '__' input type=text name=field__531 input type=text name=field__532 input type=text name=field__533 In the receiving page, split the name again. Then build a query for every record. I'm not sure whether you can string multiple queries, separated by a semicolon (;), have a try. this is a principle code (not working but it shows the idea) for checking every incoming variable for [each $key, $value in $_POST] {if (! strpos('field',$key)==false) { $key=explode('__',$key); $ID=$key[1]; mysql_query(UPDATE mytable SET WHERE ID=$ID) } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
Chris Hayes [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... for [each $key, $value in $_POST] {if (! strpos('field',$key)==false) { $key=explode('__',$key); $ID=$key[1]; mysql_query(UPDATE mytable SET WHERE ID=$ID) } } i cant get this code to work. does anybody have the working code.. tnx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
Simon wrote: Hi, I have table with six records in it. I can use while to display them all, but in form. Is there any way I can edit all six records, and update them all with one submit. TNX What do you mean with update more same fields at the same time?Can you give us an example? Gvre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
What do you mean with update more same fields at the same time?Can you give us an example? Gvre form name=form1 method=post action= ? $query1 = SELECT * FROM table where subcat = $_GET[a]; $result1 = mysql_query($query1); while($row = mysql_fetch_object($result1)) { ? p input name=textfield type=text value=? echo $row-oid; ? input name=textfield1 type=text value=? echo $row-url; ? /p ? } ? p input type=submit name=Submit value=Submit /p /form now i want to change values of texfields and update them back to mysql. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
Simon wrote: What do you mean with update more same fields at the same time?Can you give us an example? Gvre form name=form1 method=post action= ? $query1 = SELECT * FROM table where subcat = $_GET[a]; $result1 = mysql_query($query1); while($row = mysql_fetch_object($result1)) { ? p input name=textfield type=text value=? echo $row-oid; ? input name=textfield1 type=text value=? echo $row-url; ? /p ? } ? p input type=submit name=Submit value=Submit /p /form now i want to change values of texfields and update them back to mysql. If you want to update all the records that have subcat = $_GET[a] with the same values then you can do somethink like this: $subcat = $_POST['a']; $qsubcat = $_POST['subcat']; update tables set field1=$_POST['textfield'],field2='$_POST['textfield1']' where subcat='$qsubcat' I don 't know if this query will execute correctly because i don 't know the datatypes of your table fields. I prefer writing update and insert php scripts independed from select pages.It 's easier to read. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
Simon wrote: What do you mean with update more same fields at the same time?Can you give us an example? Gvre form name=form1 method=post action= ? $query1 = SELECT * FROM table where subcat = $_GET[a]; $result1 = mysql_query($query1); while($row = mysql_fetch_object($result1)) { ? p input name=textfield type=text value=? echo $row-oid; ? input name=textfield1 type=text value=? echo $row-url; ? /p ? } ? p input type=submit name=Submit value=Submit /p /form now i want to change values of texfields and update them back to mysql. If you want to update all the records that have subcat = $_GET[a] with the same values then you can do somethink like this: $subcat = $_POST['a']; $qsubcat = $_POST['subcat']; update tables set field1=$_POST['textfield'],field2='$_POST['textfield1']' where subcat='$qsubcat' I don 't know if this query will execute correctly because i don 't know the datatypes of your table fields. I prefer writing update and insert php scripts independed from select pages.It 's easier to read. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
If you want to update all the records that have subcat = $_GET[a] with the same values then you can do somethink like this: $subcat = $_POST['a']; $qsubcat = $_POST['subcat']; update tables set field1=$_POST['textfield'],field2='$_POST['textfield1']' where subcat='$qsubcat' I don 't know if this query will execute correctly because i don 't know the datatypes of your table fields. I prefer writing update and insert php scripts independed from select pages.It 's easier to read. thing is that i want to update same field 6 times with one mysql query. lets say i have 6 names in one mysql table. now I wand to update all six of them with one query. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
Simon wrote: If you want to update all the records that have subcat = $_GET[a] with the same values then you can do somethink like this: $subcat = $_POST['a']; $qsubcat = $_POST['subcat']; update tables set field1=$_POST['textfield'],field2='$_POST['textfield1']' where subcat='$qsubcat' I don 't know if this query will execute correctly because i don 't know the datatypes of your table fields. I prefer writing update and insert php scripts independed from select pages.It 's easier to read. thing is that i want to update same field 6 times with one mysql query. lets say i have 6 names in one mysql table. now I wand to update all six of them with one query. with the same data or not? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
with the same data or not? not with the same data -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update more same fields at the same time
Simon wrote: with the same data or not? not with the same data You can put your data and the primary keys in arrays and exec a loop but the data[0] must be the data for the id[0], data[1] must be the data for id[1] etc. The loop should be something like this: for (int $i=0; $i=total_records_select_returned -1; $i++) update table set field1='$data[$i]' where id=$id[$i]; I 'm not sure for the syntax but the idea is correct. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php