...

View Full Version : Queries arn't working. Why?



FlashDance
10-23-2011, 12:24 PM
I was wondering if someone could tell me why on Earth this isn't working?



<?php
$link = mysql_connect('localhost', 'testusr', 'testpw');
mysql_select_db('testdb', $link);
$queryam = "UPDATE `deliveryservices` set `zonea` = $_POST[amzonea],`zoneb` = $_POST[amzoneb],`zonec` = $_POST[amzonec],`zoned` = $_POST[amzoned],`maxweight` = $_POST[ammaxweight] where `service` = 'am'";
$queryecim = "UPDATE `deliveryservices` set `zonea` = $_POST[ecimzonea],`zoneb` = $_POST[ecimzoneb],`zonec` = $_POST[ecimzonec],`zoned` = $_POST[ecimzoned],`maxweight` = $_POST[ecimmaxweight] where `service` = 'ecim'";
$queryrp = "UPDATE `deliveryservices` set `domestic` = $_POST[rpdomestic],`maxweight` = $_POST[rpmaxweight] where `service` = 'rp'";
mysql_query ($queryam,$queryecim,$queryrp);
mysql_close($link);
?>

FlashDance
10-23-2011, 12:41 PM
I get:


PHP Warning: mysql_query() expects at most 2 parameters, 3 given


Does this mean MySQL can only handle two $things at a time?

djm0219
10-23-2011, 02:46 PM
mysql_query expects 2 things, the query to be executed and the database resource. You can't execute multiple queries with a single call to mysql_query as you are trying to do.



$mydb = mysql_select_db('testdb', $link);
$queryam = "UPDATE `deliveryservices` set `zonea` = $_POST[amzonea],`zoneb` = $_POST[amzoneb],`zonec` = $_POST[amzonec],`zoned` = $_POST[amzoned],`maxweight` = $_POST[ammaxweight] where `service` = 'am'";
$queryecim = "UPDATE `deliveryservices` set `zonea` = $_POST[ecimzonea],`zoneb` = $_POST[ecimzoneb],`zonec` = $_POST[ecimzonec],`zoned` = $_POST[ecimzoned],`maxweight` = $_POST[ecimmaxweight] where `service` = 'ecim'";
$queryrp = "UPDATE `deliveryservices` set `domestic` = $_POST[rpdomestic],`maxweight` = $_POST[rpmaxweight] where `service` = 'rp'";
mysql_query($queryam,$mydb);
mysql_query($queryecim,$mydb);
mysql_query($queryrp,$mydb);

FlashDance
10-23-2011, 03:24 PM
Ahuh! I see.

Thanks Dave. I hope you enjoy your day!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum