Hi, I am writing a booking system for a Paintball company I work for here in the UK, and I seem to be having trouble with the mysql UPDATE code.
Althogh no errors show, the mysql_affected_rows function returns -1 when I run the script.
Am I missing anything or is there an error in my code, I have been scratching my head over this all day and any help off you guys would be highley appreciated.
My Update script is:
<?
$id=$_GET['id'];
$date=$_GET['date'];
include("files/sql.connect.php");
$name=$_POST['name'];
$telephone=$_POST['telephone'];
$email=$_POST['email'];
$players=$_POST['players'];
$amountpaid=$_POST['amountpaid'];
$paytype=$_POST['paytype'];
$amountdue=$_POST['amountdue'];
$package=$_POST['package'];
$notes=$_POST['notes'];
$address=$_POST['address'];
$amountdue=0;
$query = 'UPDATE `northwestp`.`booking_system` SET `name` = \'$name\', `telephone` = \'$telephone\', `email` = \'$email\', `players` = \'$players\', `amountpaid` = \'$amountpaid\', `paytype` = \'$paytype\', `amountdue` = \'$amountdue\', `date` = \'$date\', `package` = \'$package\', `notes` = \'$notes\', `address` = \'$address\' WHERE `booking_system`.`bookid` = \'$id\' LIMIT 1;';
echo(mysql_affected_rows()); // put in to try and figure out the error
mysql_query($query) or die("Error: ".mysql_error());
echo("<font face=\"Arial\" size=\"3\">Record Updated.</font><hr>");
echo "<form>
<input type=button value=\"Close This Window\" onClick=\"javascript:window.close();\">
</form>
";
mysql_close();
?>
Any help would be greatly appreciated, Thanks in advance.
3 7262
mysql_affected rows will do nothing here because you have not executed the query.
Should be [PHP]$result = mysql_query($query);
echo mysql_affected rows($result);[/PHP]Remove the semi colon from the end of the query string.
And please get rid of the ugly escape quotes.
Either place full query in double quotes or use concatenation.
Hi, I changed the query to
$query = "UPDATE `northwestp`.`booking_system` SET `name` = '$name', `telephone` = '$telephone', `email` = '$email', `players` = '$players', `amountpaid` = '$amountpaid', `paytype` = '$paytype', `amountdue` = '$amountdue', `date` = '$date', `package` = '$package', `notes` = '$notes', `address` = '$address' WHERE `booking_system`.`bookid` = '$id' LIMIT 1;";
and changed the affected row function to
$query0=mysql_query($query);
echo(mysq_affected_rows($query0));
and I got
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /home/fhlinux200/n/northwestpaintball.co.uk/user/htdocs/booking_system/update.php on line 25
sorry if im missing the obvious, I have been at this all day with no luck
Sorry my mistake.
mysql_affected_rows() expects the link ID not the result ID.
You can pass an empty parameter and it will assume the last link ID.
Obviously it cannot count the number of rows before the query has been executed
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Westcoast Sheri |
last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database
(2 columns: "fruit" and "quantity")....so can we make these following
mySQL queries work somehow?
(visitor buys 5...
|
by: David |
last post by:
Hi,
I have a quick question.
I have a .asp application in which certain parts, clients can now
edit/update/add information to their records in our DB.
I basically use an include statement at...
|
by: jayson_13 |
last post by:
Hi,
I would like to execute a batch update (mysql) with C#. How do I do
that?
For example,
OdbcCommand cmd = New OdbcCommand();
Cmd.Connection = Conn;
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to...
|
by: PowerLifter1450 |
last post by:
I've been having a very rough time installinig mySQL on Linux. I have
been following the instructions form here:
http://www.hostlibrary.com/installing_apache_mysql_php_on_linux
Everytime I get to...
|
by: Flic |
last post by:
Hi,
I have a basic db that I access with MySQL query browser. Everything
seems fine to me but I am using this db as part of a php shopping
basket and when I try to add an item I get:
Notice:...
|
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...
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get...
|
by: ssnaik84 |
last post by:
Hi Guys,
Last year I got a chance to work with R&D team, which was working on DB scripts conversion..
Though there is migration tool available, it converts only tables and constraints..
Rest of...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |