![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I thought there was a way to do an update in the same style format as an insert, meaning: $result = mysql_query("UPDATE MyTables (Username, Password, Name, |
#3
| |||
| |||
|
|
I thought there was a way to do an update in the same style format as an insert, meaning: $result = mysql_query("UPDATE MyTables (Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('".$Username."', '".$_SESSION['Rcrd']['Psswrd']."', '".$Name."', '".$BusinessName."', '".$Phone."', '".$Email."', '".$Website."', '".$Listing."', '".$HomeCounty."', '".$HomeTown."', '".$County2."', '".$Town2."', '".$County3."', '".$Town3."') WHERE Username='".$_SESSION['Rcrd']['Usernm']."' AND Password='".$_SESSION['Rcrd']['Psswrd']."'"); |
#4
| |||
| |||
|
|
El 04/01/2012 5:16, Michael Joel escribió/wrote: I thought there was a way to do an update in the same style format as an insert, meaning: $result = mysql_query("UPDATE MyTables (Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('".$Username."', '".$_SESSION['Rcrd']['Psswrd']."', '".$Name."', '".$BusinessName."', '".$Phone."', '".$Email."', '".$Website."', '".$Listing."', '".$HomeCounty."', '".$HomeTown."', '".$County2."', '".$Town2."', '".$County3."', '".$Town3."') WHERE Username='".$_SESSION['Rcrd']['Usernm']."' AND Password='".$_SESSION['Rcrd']['Psswrd']."'"); Well, there's no need to guess, this is all documented: UPDATE [LOW_PRIORITY] [IGNORE] table_reference SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... [WHERE where_condition] [ORDER BY ...] [LIMIT row_count] http://dev.mysql.com/doc/refman/5.5/en/update.html (... or your favourite SQL reference, the basic syntax belongs to the standard.) |
#5
| |||
| |||
|
|
I thought there was a way to do an update in the same style format as an insert, meaning: $result = mysql_query("UPDATE MyTables (Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('".$Username."', '".$_SESSION['Rcrd']['Psswrd']."', '".$Name."', '".$BusinessName."', '".$Phone."', '".$Email."', '".$Website."', '".$Listing."', '".$HomeCounty."', '".$HomeTown."', '".$County2."', '".$Town2."', '".$County3."', '".$Town3."') WHERE Username='".$_SESSION['Rcrd']['Usernm']."' AND Password='".$_SESSION['Rcrd']['Psswrd']."'"); Thanks Mike |

#6
| |||
| |||
|
|
I have to say that I nearly always use sprintf in PHP to set up the query, as just a bit of extra precaution against SQL injection.. |
#7
| |||
| |||
|
|
On Wed, 04 Jan 2012 10:57:35 +0000, The Natural Philosopher tnp (AT) invalid (DOT) invalid> wrote: I have to say that I nearly always use sprintf in PHP to set up the query, as just a bit of extra precaution against SQL injection.. That offers no protection at all, not more than concatenating stuff to a query string. Best regards, |
#8
| |||
| |||
|
|
I thought there was a way to do an update in the same style format as an insert, meaning: $result = mysql_query("UPDATE MyTables *(Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('".$Username."', '".$_SESSION['Rcrd']['Psswrd']."', '".$Name."', '".$BusinessName."', '".$Phone."', '".$Email."', '".$Website."', '".$Listing."', '".$HomeCounty."', '".$HomeTown."', '".$County2."', '".$Town2."', '".$County3."', '".$Town3."') WHERE Username='".$_SESSION['Rcrd']['Usernm']."' AND Password='".$_SESSION['Rcrd']['Psswrd']."'"); Thanks Mike |
#9
| |||
| |||
|
|
On Jan 4, 4:16 am, Michael Joel<n... (AT) please (DOT) com> wrote: I thought there was a way to do an update in the same style format as an insert, meaning: $result = mysql_query("UPDATE MyTables (Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('".$Username."', '".$_SESSION['Rcrd']['Psswrd']."', '".$Name."', '".$BusinessName."', '".$Phone."', '".$Email."', '".$Website."', '".$Listing."', '".$HomeCounty."', '".$HomeTown."', '".$County2."', '".$Town2."', '".$County3."', '".$Town3."') WHERE Username='".$_SESSION['Rcrd']['Usernm']."' AND Password='".$_SESSION['Rcrd']['Psswrd']."'"); Thanks Mike You've got it the wrong way round. In MySQL it is possible to do an INSERT using a similar format to an UPDATE. but the converse isn't necessarily true. And if you're building your string using double quotes, do yourself a favour and dumb all the "."s, thus: $result = mysql_query("UPDATE MyTables (Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('$Username', "{$_SESSION['Rcrd']['Psswrd']}', '$Name', '$BusinessName', '$Phone', '$Email', '$Website', '$Listing', '$HomeCounty', '$HomeTown', '$County2', '$Town2', '$County3', '$Town3') WHERE Username='{$_SESSION['Rcrd']['Usernm']}' AND Password='{$_SESSION['Rcrd']['Psswrd']}'"); But even better would be to format your query neatly! |
#10
| |||
| |||
|
|
On Jan 4, 4:16 am, Michael Joel<n... (AT) please (DOT) com> wrote: I thought there was a way to do an update in the same style format as an insert, meaning: $result = mysql_query("UPDATE MyTables (Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('".$Username."', '".$_SESSION['Rcrd']['Psswrd']."', '".$Name."', '".$BusinessName."', '".$Phone."', '".$Email."', '".$Website."', '".$Listing."', '".$HomeCounty."', '".$HomeTown."', '".$County2."', '".$Town2."', '".$County3."', '".$Town3."') WHERE Username='".$_SESSION['Rcrd']['Usernm']."' AND Password='".$_SESSION['Rcrd']['Psswrd']."'"); Thanks Mike You've got it the wrong way round. In MySQL it is possible to do an INSERT using a similar format to an UPDATE. but the converse isn't necessarily true. And if you're building your string using double quotes, do yourself a favour and dumb all the "."s, thus: $result = mysql_query("UPDATE MyTables (Username, Password, Name, BusinessName, Phone, Email, Website, Listing, County, Town, County2, Town2, County3, Town3) values ('$Username', "{$_SESSION['Rcrd']['Psswrd']}', '$Name', '$BusinessName', '$Phone', '$Email', '$Website', '$Listing', '$HomeCounty', '$HomeTown', '$County2', '$Town2', '$County3', '$Town3') WHERE Username='{$_SESSION['Rcrd']['Usernm']}' AND Password='{$_SESSION['Rcrd']['Psswrd']}'"); But even better would be to format your query neatly! |
![]() |
| Thread Tools | |
| Display Modes | |
| |