not sure why $query tested on server/mysql is not going through on script

solunatec
solunatec used Ask the Experts™
on
I have the following tables;

accounts_table:   (list the accounts)
account_uid
account_name
physical_address
city
state_prov
country
zip

wo_stats:  (connected to accounts by uid, list the info for job which will not change)
todays_date
work_order_uid
account_uid
billable_or_non
work_date
jobe_time
payout
est_supply_cost
comment

wo_table:  (since most jobs are sub jobs this info is cumulative, connected by work_order_uid, to table work_stats).
work_order_uid
jobe_cod
projected_hours
sqr_footage
surface_code

my $qeury is as follows:
$query="select * a.account_name, ws.work_order_uid  
from accounts_table As a
INNER JOIN wo_stats As ws ON  a.account_uid = ws.account_uid";

the idea is to put the opened work orders in a drop down list so that one may add jobs to the
work order....it would consist of the account_name and the work_order_uid.... : I plan to have them click that and the basic information would be pre-filled on a form and only the wo_table info wold have to be filled in: using of course the same uid for the job as in the wo_stats table;
I just cant get the $query to populate using various scripts one which I will include.

like I said $query works on the same mysql installation directly queryied on database but I figure something is not working as directly as I think it should......
<html>
<head><title>opened work orders</title></head>
<body>

<?php

$user="xxxx";

$host="xxxxxx";
$password="xxxxxx";
$database = "xxxxxxxx";
$cxn = mysqli_connect($host,$user, $password, $database)
or die ("couldn’ t connect to server" ) ;


$query="select * a.account_name, ws.work_order_uid  
from accounts_table As a 
INNER JOIN wo_stats As ws ON  a.account_uid = ws.account_uid"; 



$result = mysqli_query($cxn,$query)
or die ( " Couldn’ t execute query." ) ;
/* create form containing selection list */
echo "form action='add_to_wo.php' method= 'POST' >
<select name='account_name' >\n”";
while ($row = mysqli_fetch_assoc($result) )
{ 
extract($row) ;
echo "<option value='$account_name' >$account_name\n" ;
}
echo "</select>\n"  ;
echo "<input type='submit' value=' Select Opened workorder' >
</form>\n";
?>
</body></html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chief Technology Officer
Most Valuable Expert 2011
Commented:
It appears you are missing a comma or copy and pasted * by accident.

$query="select * a.account_name, ws.work_order_uid  
from accounts_table As a
INNER JOIN wo_stats As ws ON  a.account_uid = ws.account_uid";

This should be:

// probably a.* or ws.*, but anything with * not recommended
// explicitly list columns if you can
$query="select *, a.account_name, ws.work_order_uid  
from accounts_table As a
INNER JOIN wo_stats As ws ON  a.account_uid = ws.account_uid";

or

$query="select a.account_name, ws.work_order_uid  
from accounts_table As a
INNER JOIN wo_stats As ws ON  a.account_uid = ws.account_uid";


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial