[PHP-DB] multiple queries with PHP

2003-09-05 Thread John Ryan
I want to SELECT * from a table and also update the hit counter by 1. So
theres 2 different queries which I know I can easily do in PHP seperately,
but I thought itd be quicker and more efficient to run them in the same
query, ie seperated by a ';'.

But PHP returns an error, and it works fine on the command line. I read
somewhere thats its a security risk in PHP to allow 2 queries, so its turned
off by default. Is this true?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] multiple queries with PHP

2003-09-05 Thread John W. Holmes
John Ryan wrote:

I want to SELECT * from a table and also update the hit counter by 1. So
theres 2 different queries which I know I can easily do in PHP seperately,
but I thought itd be quicker and more efficient to run them in the same
query, ie seperated by a ';'.
But PHP returns an error, and it works fine on the command line. I read
somewhere thats its a security risk in PHP to allow 2 queries, so its turned
off by default. Is this true?
Yes.

Also, just because you can fit something onto one line it doesn't mean 
it's more efficient.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] multiple queries with PHP

2003-09-05 Thread John Ryan
You wouldnt know where to change this setting?

John W. Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 John Ryan wrote:

  I want to SELECT * from a table and also update the hit counter by 1. So
  theres 2 different queries which I know I can easily do in PHP
seperately,
  but I thought itd be quicker and more efficient to run them in the same
  query, ie seperated by a ';'.
 
  But PHP returns an error, and it works fine on the command line. I read
  somewhere thats its a security risk in PHP to allow 2 queries, so its
turned
  off by default. Is this true?

 Yes.

 Also, just because you can fit something onto one line it doesn't mean
 it's more efficient.

 --
 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 php|architect: The Magazine for PHP Professionals – www.phparch.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] multiple queries with PHP

2003-09-05 Thread John W. Holmes
John Ryan wrote:

You wouldnt know where to change this setting?
It's not a setting, you just can't do it. Use two mysql_query() calls.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] multiple queries in PHP to mysql database.

2003-03-28 Thread Ronan Chilvers
Hi Jerry

Inline comments

On 28 Mar,2003 at 12:31 JeRRy JeRRy wrote:

 
 How can I update 2 tables at once if a match occours
 from information inputed into a PHP form.
 

How about turning this around and re-organising the data a little?

Why not have a single score table with references to a central username / pw / id 
table.  

Table 1 - users

id
username
password

Table 2 - scores

id
userid
game1
game2
game3
game4
...
overall


You can then do

UPDATE table2 SET game1=game1+1, overall=overall+1 WHERE userid = $userid

Getting a results table would then be a single query...

Does this help at all ?  Hopefully I've grasped enough of the concept to not make a 
complete fool of myself !

 
 Jerry
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] multiple queries in PHP to mysql database.

2003-03-27 Thread JeRRy

Hi,

I just noticed a problem with my question which would
cause major problems in my db.  So let me re-ask it
again.

How can I update 2 tables at once if a match occours
from information inputed into a PHP form.

Now this is what each table has.

table1:
id
username
game1
game2
game3
game4
game5
game6
game7
game8
score

table2:
id
username
password
sid
score

I have this:

$sql = UPDATE table1 SET score=score+1 WHERE
$select='$winner';
   
mysql_query($sql);
echo(Points credited?  I hope!brbr);
}
else {echo(An error occoured, please click back
button and try again.);}

Now that works fine and updates correctly.

But now I want a second table to be updated.  So if
username blah got +1 I need table2 to update it's
score for blah to +1.  The query above updates if it
finda a match in table1 and does not require the use
of a username to update.  But for table2 I am guessing
it WILL need to know the username or id to update the
appropiate field and not update everyones score to +1.
 So how is this achieved? Or am I doing this a hard
way?

Jerry



http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP-DB] multiple queries in PHP to mysql database.

2003-03-27 Thread Blain
Hi

After Updateing the table1:
SELECT username, score FROM table1 WHERE $select='$winner';
Then you have your Informations..

Cya Blain

-Ursprüngliche Nachricht-
Von: JeRRy [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 28. März 2003 02:31
An: [EMAIL PROTECTED]
Betreff: [PHP-DB] multiple queries in PHP to mysql database.



Hi,

I just noticed a problem with my question which would
cause major problems in my db.  So let me re-ask it
again.

How can I update 2 tables at once if a match occours
from information inputed into a PHP form.

Now this is what each table has.

table1:
id
username
game1
game2
game3
game4
game5
game6
game7
game8
score

table2:
id
username
password
sid
score

I have this:

$sql = UPDATE table1 SET score=score+1 WHERE
$select='$winner';

mysql_query($sql);
echo(Points credited?  I hope!brbr);
}
else {echo(An error occoured, please click back
button and try again.);}

Now that works fine and updates correctly.

But now I want a second table to be updated.  So if
username blah got +1 I need table2 to update it's
score for blah to +1.  The query above updates if it
finda a match in table1 and does not require the use
of a username to update.  But for table2 I am guessing
it WILL need to know the username or id to update the
appropiate field and not update everyones score to +1.
 So how is this achieved? Or am I doing this a hard
way?

Jerry



http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] multiple queries in PHP ????

2003-03-24 Thread JeRRy
Hi,

I have a query to update a database via PHP after a
form is inputed.  The form results do a match to the
database and if a match occours updates a field with
+1 and if no matches it does nothing.  

Now I want it so if +1 is done I want another table to
update as +1 also.  How would I achieve this in PHP? 
I'd prefer to keep it all on one page to make it alot
easier to manage.  SO if +1 in table1 than update
table2 with +1 also.  If no matches than do nothing to
both.

Could someone please help me with this, is it a 'if'
statement or something?  Help is appreciated and
thanks in advance.

I alsready have the script to update table1 and does
this fine but am not sure how to do mulitple queries
in the one PHP page.

Jerry

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php