zero-perfoliate
zero-perfoliate

Author Topic: PHP - INSERT using multiple SELECT statements with MySQL  (Read 2363 times)

Offline chris

  • PHP Workers
  • **
  • Posts: 10
  • Karma: +0/-0
Re: PHP - INSERT using multiple SELECT statements with MySQL
« Reply #15 on: March 09, 2009, 03:58:54 PM »
Hey thanks for the reply. I've often wondered whether the vars held actual values or just true/false as you mentioned.
I tried adapting your idea on the $P (Played) variable as follows:

$GetP = mysql_query("SELECT COUNT(team_name) FROM performance WHERE team_name='Avengers'");
$row = mysql_fetch_object($GetP);
$P = $row->played;

However on the last line ($P = $row->played;) it seem doesn't to like it, showing the following error message:

Undefined property: stdClass::$played

When I saw this I tried using it on the $ID var and it had the same affect.

Also I should mention that it is still inserting values as 0.

Offline chris

  • PHP Workers
  • **
  • Posts: 10
  • Karma: +0/-0
Re: PHP - INSERT using multiple SELECT statements with MySQL
« Reply #16 on: March 10, 2009, 09:26:19 AM »
Hi there, I realised I was being a bit of a noob. It wasn't working because I was taking the last line exactly (e.g. $ID = $row->team_id;) instead i replaced it with $GF = $row['SUM(goals_scored)']; (from the Goals For query).

As soon is I changed it the query works fine every time it was exactly how you said the queiries weren't holding any values.

Any way thanks a lot for all your help it is very much appreciated, now I will be able to continue programming and use this in future queries.

Offline PhPHelper

  • http://Digiscapers.com
  • Full Member
  • PHP Problem Solvers
  • ****
  • Posts: 179
  • Karma: +50/-0
    • Bad Apple Mail
Re: PHP - INSERT using multiple SELECT statements with MySQL
« Reply #17 on: March 10, 2009, 09:32:54 AM »
excellent glad you got it working, I missed that as well  ::)


 

zero-perfoliate