473,698 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error syntax to update mysql data

3 New Member
Hi !
this is my first post
where is my error code in line 15 ($sql )

<html>
<head><title> update MySQL Data </title></head>
<body bgcolor="#FFFFF F">

<?

$DBhost = "dbhost";
$DBuser = "dbuser";
$DBpass = "dbcode";
$DBName = "dbname";
$JANpass ="new code";

$connect=mysql_ connect($DBhost ,$DBuser,$DBpas s) or die("Unable toconnect to database");
mysql_select_db ("$DBName") or die("Unable to select database $DBName");
$sql = 'UPDATE `jos_users` SET `password` = MD5( \'1q2w3e\' ) WHERE `username` = \'admin\';';
mysql_query($sq l) or die ("not change your admin pass");
echo="The new pass is $JANpass";
mysql_close($co nnect)

?>
</BODY></HTML>

Thanks!
Dec 9 '06 #1
4 2161
ronverdonk
4,258 Recognized Expert Specialist
Set your query within double quotes, your content must be within single quotes because you update a character type field. The single quotes are not part of the content, just a wrapper.
Expand|Select|Wrap|Line Numbers
  1. $sql = "UPDATE `jos_users` 
  2.        SET `password` = MD5('1q2w3e' ) 
  3.        WHERE `username` = 'admin'";
Ronald :cool:
Dec 9 '06 #2
geof
3 New Member
before send the post try for this but don' t work. and generated the upgrade code from phpmyAdmin and also doesn' t work.

Thanks for your help
Sorry for my English
Dec 9 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
The syntax of the UPDATE statement is correct. You'd better show us the error description that you get on the statement.

But in order to do that you must do what you should have done to begin with: it is a good custom to 'catch' the error messages you receive after any command, whether MySQL or file or whatever, that can return an error.

So you must change your statement like shown here. I suggest you do the same for the other 'non-captured' MySQL statements in your code.
[php]mysql_query($sq l)
or die ("not change your admin pass, error: ". mysql_error());
[/php]
Ronald :cool:
Dec 9 '06 #4
geof
3 New Member
Ronald

T H A N K S !!!
Solved

The full correct code is

<html>
<head><title> update MySQL Data </title></head>
<body bgcolor="#FFFFF F">

<?
/* declare some relevant variables */
$DBhost = "dbhost";
$DBuser = "dbuser";
$DBpass = "dbcode";
$DBName = "dbname";
$JANpass ="new code";

$condb=mysql_co nnect($DBhost,$ DBuser,$DBpass) or die("Unable to connect to database".mysql _error());
mysql_select_db ("$DBName") or die("Unable to select database $DBName,error:" .mysql_error()) ;
$sql = "UPDATE `jos_users`
SET `password` = MD5('$JANpass' )
WHERE `username` = 'admin'";
mysql_query($sq l) or die ("not change your admin pass,error:".my sql_error());
echo "The new admin pass is '$JANpass'";
mysql_close($co ndb)

?>
</BODY></HTML>
Dec 9 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5032
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
0
2806
by: Ola Ogunneye | last post by:
--=_075912CF.F899D547 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello again all, I have created an account in the particular database that I was trying to backup Using PHPMYADMIN and I also created the same user account on the OS side. I still got the same 1064 message afterwards. I am still relatively new to Mysql and my adding user only works when I use
0
1193
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select database(); +------------+ | database() | +------------+
0
3039
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
7
7408
by: Adam Smith | last post by:
Hope this is the right news group!! I did a server upgrade and at the same time did a mysql update from 4.0.12 to Ver 12.22 Distrib 4.0.16 mach1# mysql --version mysql Ver 12.22 Distrib 4.0.16, for portbld-freebsd4.9 (i386) I attempted to restore the DB with
1
8832
by: Mikey G | last post by:
Hi, I created a simple VB.NET 2003 application through Visual Studio that connects to a MySQL database and loads a table into a Dataset, and then displays that table information in a DataGrid on a form for editing. The table fill works fine, the delete function works fine, but when I try to update a row, the application fails with the following error message: An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in...
6
2459
by: Mikey G | last post by:
Hi, Here is a shorter code example since the last message I posted got truncated. So the problem is I created a simple VB.NET 2003 application through Visual Studio that connects to a MySQL database and loads a table into a Dataset, and then displays that table information in a DataGrid on a form for editing. The table fill works fine, the delete function works fine, but when I try to update a row, the application fails with the...
1
3368
by: ajos | last post by:
hi evrybdy, the problem is:- i had this running before in jsp but when i changed the jsp page using struts tags there occoured a problem... when i enter values in the 2 text boxes and click enter an exception occours which is- type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request.
6
1903
by: jwgrafflin | last post by:
I keep getting the same error: This code works just fine on another site, and all the other php pages work just fine. But this one is driving me nuts trying to figure out the problem. <?php $hostname=$_POST; $url=$_POST; $established=$_POST;
3
4955
by: phobia1 | last post by:
Hi once again. We have just changed our ISP and things that worked fine now do not, Obviously its in the differences of MYSQL and PHP versions. Have fixed most of the problems but this UPDATE routine has got me foxed. <?PHP // update.php require("./resources/globals.php") ; require("./resources/common.php") ; //echo $detail;
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.