For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2005 > RE: [PHP-DB] Can someone help me out?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [PHP-DB] Can someone help me out?
reclmaples@sbcglobal.net

2005-06-08, 8:57 am

This makes sense but I can't figure out how it should look in the field,can
you help?

Here is what I currently have:

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 run it like this, I get this in my web server error log:

PHP Parse error: parse error in Off_Stat_Leaders.php(35) : eval()'d code on
line 1, referer: Offensive_Stat_Search.php

Any ideas?

Thanks
-Rich

-----Original Message-----
From: Brad Webb [mailto:bradleypaulwebb@gmail.com]
Sent: Tuesday, June 07, 2005 8:37 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Can someone help me out?

eval($recss[sql1]).. variables inside a string have to be expanded
manually, since you're storing the variable names inside the DB, you
have to manually pull them out..

Sorry for not catching this earlier, I didn't realize the query itself
was stored in the DB.


ReClMaples wrote:

>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@hotmail.com]
>Sent: Tuesday, June 07, 2005 7:21 PM
>To: reclmaples@sbcglobal.net; desktophero@cox.net
>Cc: php-db@lists.php.net
>Subject: RE: [PHP-DB] 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
>
>
>
desc[color=darkred]
and[color=darkred]
>
>--
>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




****************************************
******************************

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.

****************************************
********************************
<<<<GWAVAsig>>>>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com