Hi,
I have a MySQL database where I want to updated multiple records. The
table has two columns:
product_number
product_price
I have a list with first entry product_price, second entry
product_number
@products_param = (
['11.90', '1034K'],
['22.90', '1034R'],
['43.90', '1034U']
); # no comma after last entry
I run the following from a file on the server:
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
####### Start products_param FOR loop
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
###### Start products_param FOR loop ######
$compiled = $dbh->prepare("
UPDATE products
SET products_price = ?
WHERE products_model = ?
VALUES (?,?)
");
foreach ($products_para m as $products) {
$dbh->execute($compi led, $products);
};
This gives me an "Internal Server" error. I have several PHP and MySQL
books but cannot find the correct syntax.
Any help appreciated.
Al Moodie. 6 1814
On Sep 2, 11:37*am, Al Moodie <nos...@nospam. comwrote:
Hi,
I have a MySQL database where I want to updated multiple records. The
table has two columns:
product_number
product_price
I have a list with first entry product_price, second entry
product_number
@products_param = (
* * * * * * * * ['11.90', '1034K'],
* * * * * * * * ['22.90', '1034R'],
* * * * * * * * ['43.90', '1034U']
* * * * * * * * ); # no comma after last entry
I run the following from a file on the server: * * * * *
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
####### Start products_param FOR loop
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
###### Start products_param FOR loop ######
$compiled = $dbh->prepare("
* * * * UPDATE products
* * * * SET products_price = ?
* * * * WHERE products_model = ?
* * * * VALUES (?,?)
* * * * ");
foreach ($products_para m as $products) {
$dbh->execute($compi led, $products);
};
This gives me an "Internal Server" error. I have several PHP and MySQL
books but cannot find the correct syntax.
Any help appreciated.
Al Moodie.
seems to be error in this
where have you declared this?
@products_param = (
['11.90', '1034K'],
['22.90', '1034R'],
['43.90', '1034U']
);
--------------------- http://www.webxan.com
---------------------
On 2 Sep, 16:37, Al Moodie <nos...@nospam. comwrote:
Hi,
I have a MySQL database where I want to updated multiple records. The
table has two columns:
product_number
product_price
I have a list with first entry product_price, second entry
product_number
@products_param = (
* * * * * * * * ['11.90', '1034K'],
* * * * * * * * ['22.90', '1034R'],
* * * * * * * * ['43.90', '1034U']
* * * * * * * * ); # no comma after last entry
I run the following from a file on the server: * * * * *
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
####### Start products_param FOR loop
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
###### Start products_param FOR loop ######
$compiled = $dbh->prepare("
* * * * UPDATE products
* * * * SET products_price = ?
* * * * WHERE products_model = ?
* * * * VALUES (?,?)
* * * * ");
foreach ($products_para m as $products) {
$dbh->execute($compi led, $products);
};
This gives me an "Internal Server" error. I have several PHP and MySQL
books but cannot find the correct syntax.
Any help appreciated.
Al Moodie.
I have never seen that syntax for the execute method. Where are you
getting it from?
On Tue, 2 Sep 2008 09:00:05 -0700 (PDT), Captain Paralytic
<pa**********@y ahoo.comwrote:
> I have never seen that syntax for the execute method. Where are you getting it from?
I "adapted" it from an INSERT placeholder query in a PHP book. If you
know the correct sytax please let me know.
Al Moodie.
$compiled = $dbh->prepare("
>
UPDATE products
SET products_price = ?
WHERE products_model = ?
VALUES (?,?)
");
I think the VALUES line is a problem anyhow. It does not belong in an
UPDATE query.
If you want to know what happens, enable the querylog (in my.cnf). I
assume you are developing on your local database, where enabling the
querylog is not a space/performance issue.
To check the log "live" there are quite nice log viewers, like multitail
(linux) or BareTail (windows or wine). You can then see what is really
sent to the server.
Best regards,
--
Willem Bogaerts
Application smith
Kratz B.V. http://www.kratz.nl/
On Sep 2, 4:37 pm, Al Moodie <nos...@nospam. comwrote:
Hi,
I have a MySQL database where I want to updated multiple records. The
table has two columns:
product_number
product_price
I have a list with first entry product_price, second entry
product_number
@products_param = (
['11.90', '1034K'],
['22.90', '1034R'],
['43.90', '1034U']
); # no comma after last entry
I run the following from a file on the server:
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
####### Start products_param FOR loop
$dbh = DBI->connect($dsn , $login_name, $password)
or die "(Can't connect to MySQL database: $DBI::errstr\n" ;
###### Start products_param FOR loop ######
$compiled = $dbh->prepare("
UPDATE products
SET products_price = ?
WHERE products_model = ?
VALUES (?,?)
");
foreach ($products_para m as $products) {
$dbh->execute($compi led, $products);
};
This gives me an "Internal Server" error. I have several PHP and MySQL
books but cannot find the correct syntax.
Any help appreciated.
Al Moodie.
What's with the VALUES line? i've never seen that in a update
statement before.
If you want to update wveral rows at once so that a column holds the
same value you'd do UPDATE table SET column = ? WHERE key IN (?); KEY
would then take a list of keys seperated by commas. For example to
update rows with key values 3, 7 and 10 you'd pass 3,7,10 to the
prepared query.
On 2 Sep, 16:37, Al Moodie <nos...@nospam. comwrote:
Hi,
I have a MySQL database where I want to updated multiple records. The
table has two columns:
product_number
product_price
I have a list with first entry product_price, second entry
product_number
Hi Al,
I'd suggest re-writing your code in PHP and SQL - cos whatever you are
writing looks like neither:
@products_param = (
['11.90', '1034K'],
['22.90', '1034R'],
['43.90', '1034U']
); # no comma after last entry
I guess this is meant to be:
$products_param = array (
array ('11.90', '1034K'),
array ('22.90', '1034R'),
array ('43.90', '1034U')
); // no comma after last entry
(PHP will happily accomodate a trailing , in the array params - some
codingstandards even require it).
UPDATE products
SET products_price = ?
WHERE products_model = ?
VALUES (?,?)
WTF?
Do you mean
UPDATE products
SET products_price = ?
WHERE products_model = ?
C. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dukeofwhelmsley |
last post by:
Hello,
I have a database generated form that I would like users to be able to
update by selecting a checkbox. Say the page displayed has six records
on it and the user wants to delete one or more of the records. They
would click the checkbox and hit a "delete" button. Then the database
would be updated and the user redirected back to the page that would
now show all the records that weren't deleted. Sort of like Yahoo
mail, you get a list...
|
by: Roy Adams |
last post by:
Hi everyone
I'm trying to build a shopping cart app using a db the part I'm stuck
on is the fact that, if someone adds a product that they have
previously added to the cart.
I've got it set up to check whether the size and colour fields match
what's in the db, if they do then you've already added this item with
the same colours and size so, only update the quantity field, if they
don't match, then insert a new record because the size and...
|
by: Hennie de Nooijer |
last post by:
Hi,
Currently we're a building a metadatadriven datawarehouse in SQL
Server 2000. We're investigating the possibility of the updating
tables with enormeous number of updates and insert and the use of
checkpoints (for simple recovery and Backup Log for full recovery).
On several website people speak about full transaction log and the
pace of growing can't keep up with the update. Therefore we want to
create a script which flushes the...
|
by: CSDunn |
last post by:
Hello,
I have an Access 2000 Project in which the data comes from a SQL Server 2000
database, and multiple users need to be able to see new records as each user
adds records. The users also need to be aware of updates as they are made to
current records. The data the users are looking at is presented in a subform
that has the Default View property set to 'Single Form'.
In order for each user to see the update to the current record as...
|
by: Tc |
last post by:
Hi,
I was curious, I am thinking of writing an application that loads a dataset
from a database that resides on a server. The question I have is this, if
multiple copies of the app will be running at once will there be problems
with data updates?
The reason I ask is I'm thinking like this:
User1 launches the app and the dataset is created from the data in the DB.
| |
by: Jeff |
last post by:
For years I have been using VBA extensively for updating data to tables
after processing. By this I mean if I had to do some intensive processing
that resulted in data in temp tables, I would have VBA code that wrote the
results of that away to the db, either creating new records or updating
existing records, whichever was relevant. This may also include deleting
records.
Now I generally do this by opening a recordset on the source data...
|
by: mike11d11 |
last post by:
I'm trying to create an application that will have multiple users
working off a table on a SQL server. Since multi users will be
updating different records at any given moment, how can i get those
changes and merge them into my current Dataset. I've been playing
around with the GetChanges method and Acceptchanges but they just dont
seem to be pulling over the changes and updating my Dataset. Maybe if
someone could give me a sample of...
|
by: chimambo |
last post by:
Hi All,
I have a little problem. I am retrieving records from a table and I
want to update the records using checkboxes. I am able to display the
database record quite alright and I have created an array of
checkboxes, but my update loop is not working. Here is my code:
/*---------This retrieves the records -------------*/
if($row_md)
{
do{
echo "<tr><td text align='right'>";
|
by: jwbird |
last post by:
I have a main form with multiple Subforms that are all displaying Datasheet information related to the Main form record. When I make changes/adds to the records(s) in the subform and tab to another subform, it saves those previous subform records fine, but when I make changes to the subform records and then change the mainform criteria, it doesn't save those subform records.
I can use an event to prompt for saving the records on the...
|
by: Bill Schanks |
last post by:
I have a winform app (VB 2005) that allows users to export data to
excel, make updates to the excel file and import the data from that
Excel file and update the database.
My question is: Is it best to do it this way, calling the update
stored procedure for every update? Or should I be loading this data
into a staging table, and if all goes well do the 'Real' Update. Or
put this into a data adapter and update from that? The application...
|
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,...
| |
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
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...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |