RE: Can someone help me out?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All,

   Here is the code that I'm using.  I have a form that feeds that top
values to this page:

<?php

$pos = $_POST['sel_pos_name'];
$year = $_POST['sel_year_name'];
$cat_name = $_POST['sel_cat_name'];
$display = $_POST['display'];
$div = $_POST['Div'];


//MySql and Database Connection
$conn = mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("",$conn)  or die(mysql_error());


//Gets the id,cat_name,sql1 field sql2 field and cat_descript from the table
$get_cat_info = "select Id,Cat_Name,Cat_Descript,sql1,sql2 from
stat_categories where Cat_Name = '$cat_name'";
$get_cat_info_res = mysql_query($get_cat_info) or die(mysql_error());

while ($recss = mysql_fetch_array($get_cat_info_res))
{
    $id = $recss['Id'];
    $cat_name1 = $recss['Cat_Name'];
    $cat_descript = $recss['Cat_Descript'];
    $sql1 = $recss['sql1'];
    $sql2 = $recss['sql2'];
}

//Displays the top of the table
echo "<b>Results for $cat_name</b>";
echo "<table border='1' cellpadding='1' cellspacing='1'>";
echo "<tr>";
echo "<td bgcolor=\"#C0C0C0\"><center><b>Player Name</b></center></td>";
echo "<td bgcolor=\"#C0C0C0\"><center><b>Position</b></center></td>";
echo "<td bgcolor=\"#C0C0C0\"><center><b>Team</b></center></td>";
echo "<td bgcolor=\"#C0C0C0\"><center><b>$cat_descript</b></center></td>";
echo "</tr>";

if ($div == 'NFL')
{
//sql2

$get_results = "$sql2 limit $display";

//echo $get_results;

$get_results_res = mysql_query($get_results) or die(mysql_error());

while ($res = mysql_fetch_array($get_results_res))
	{
	$player_name = $res['name'];
	$position = $res['position'];
	$team = $res['team'];
	$Results = $res['Results'];

		echo "<tr>";
		echo "<td><center>$player_name</center></td>";
		echo "<td><center>$position</center></td>";
		echo "<td><center>$team</center></td>";
		echo "<td><center>$Results</center></td>";
		echo "</tr>";
		echo "</table>";


	}

}
else
{
//sql1

$get_resultss = "$sql1  limit $display";

echo $get_results1;
$get_results_res1 = mysql_query($get_results1) or die(mysql_error());

while ($res1 = mysql_fetch_array($get_results_res1))
{
	$player_name = $res1['name'];
	$position = $res1['position'];
	$team = $res1['team'];
	$Results = $res1['Results'];

		echo "<tr>";
		echo "<td><center>$player_name</center></td>";
		echo "<td><center>$position</center></td>";
		echo "<td><center>$team</center></td>";
		echo "<td><center>$Results</center></td>";
		echo "</tr>";
		echo "</table>";

	}
}

?>

There are no functions and I'm using double quotes.  In my table.  I have
two fields sql1 and sql2.

Here are the values in each of the fields:

Sql1
select a.name,a.position,a.team,sum(b.yards) as Results from player
a,passing b
where
a.player_num = b.player_num
and a.position = '$pos'
and b.year >= '$year'
and a.team_div = '$div'
group by a.name
order by Results desc

Sql2
select a.name,a.position,a.team,sum(b.yards) as Results from player
a,passing b
where
a.player_num = b.player_num
and a.position = '$pos'
and b.year >= '$year'
group by a.name
order by Results desc

I'm stumped.  I have tested each variable and they all come back, except in
the variables sql1 and sql2.

Thanks
-Rich
-----Original Message-----
From: Bastien Koert [mailto:bastien_k@xxxxxxxxxxx]
Sent: Tuesday, June 07, 2005 7:21 PM
To: reclmaples@xxxxxxxxxxxxx; desktophero@xxxxxxx
Cc: php-db@xxxxxxxxxxxxx
Subject: RE:  Can someone help me out?

can you show the code around it? are you using single quotes in defining the
sql statement? or double quotes?

Bastien

>From: "ReClMaples" <reclmaples@xxxxxxxxxxxxx>
>To: "Jason Walker" <desktophero@xxxxxxx>
>CC: "PHP" <php-db@xxxxxxxxxxxxx>
>Subject: RE:  Can someone help me out?
>Date: Tue, 7 Jun 2005 19:00:59 -0500
>
>Jason,
>
>    After looking at this a little more, the variable aren't being changed
>into their value.
>
>The echo looks like this:
>
>select a.name,a.position,a.team,sum(b.yards) as Results from player
>a,passing b where a.player_num = b.player_num and a.position = $pos and
>b.year >= $year and a.team_div = $div group by a.name order by Results desc
>limit '$display'
>
>As you can see the variables aren't being changed, any ideas?
>
>Thanks
>-Rich
>
>-----Original Message-----
>From: Jason Walker [mailto:desktophero@xxxxxxx]
>Sent: Tuesday, June 07, 2005 6:54 PM
>To: 'ReClMaples'
>Subject: RE:  Can someone help me out?
>
>
>In your PHP page, can you echo the actual query variable to the browser and
>send that to the mail group?
>
>I don't necessary see anything 'wrong' with your query but see the three
>variables, as they are interpreted by PHP, may help.
>
>Thanks,
>
>-----Original Message-----
>From: ReClMaples [mailto:reclmaples@xxxxxxxxxxxxx]
>Sent: Tuesday, June 07, 2005 4:05 PM
>To: PHP
>Subject:  Can someone help me out?
>
>I am having a problem getting a sql statement to run.
>
>I have this in a table called stat_categories, in a field called sql2
>
>select a.name,a.position,a.team,sum(b.yards) as Results from player
>a,passing b where a.player_num = b.player_num and a.position = '$pos'
>and b.year >= '$year'
>group by a.name
>order by Results desc
>limit '$display'
>
>when I try to display this I get this error:
>
>You have an error in your SQL syntax. Check the manual that corresponds to
>your MySQL server version for the right syntax to use near ''$display'' at
>line 8
>
>I tried removing the ''s but this didn't help.
>
>If I put in the sql instead of the variable, it works fine.  What am I
>doing
>wrong?
>
>Any help would be greatly appreciated.
>
>Thanks
>-Rich
>
>
>
>--
>No virus found in this outgoing message.
>Checked by AVG Anti-Virus.
>Version: 7.0.323 / Virus Database: 267.6.5 - Release Date: 6/7/2005
>
>--
>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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux