Jump to content

Recommended Posts

Hi All, this wont work and I don't know why.  I've done the same for "filter by pname" and that works, but this wont .... Can you see what I'm doing wrong?? It's driving me crazy!!  :'(

 

<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=yearfull> 
<OPTION VALUE=0>Choose 
<?=$options1?> 
</SELECT> 
<input type="submit" name="submit1" value="submit1">
</FORM>

<?php
//DISPLAY FILTER BY YEAR//
$yearfull=$_GET['yearfull'];
echo $yearfull;
if(isset($_GET['submit1'])){


$sql4="select pname, award, year_full
FROM pname, award, aw_result, year
WHERE pname.name_id=aw_result.pname_id
AND award.award_id=aw_result.award_id
and year.year_id=aw_result.year_id
and year_full='$yearfull'
order by award;"; 
}
$yearaw=mysql_query($sql4);
while($row1 = mysql_fetch_array($yearaw))
{
echo '<br />';
echo $row1['pname'] . '<br />';
echo $row1['award'] . '<br />';
}

if(isset($_GET['submit1'])) {

$sql5="select pname, comp, place_name
FROM pname, comp, comp_result, place
WHERE pname.name_id=comp_result.pname_id
AND comp.comp_id=comp_result.comp_id
AND place.place_id=comp_result.place_id
and comp_year='$yearfull'
order by place.place_id;";
}
$yearcomp=mysql_query($sql5);
while($row1 = mysql_fetch_array($yearcomp))
{
echo '<br />';
echo $row1['place_name'] . '<br />';
echo $row1['pname'] . '<br />';
echo $row1['comp'] . '<br />';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/182834-why-wont-this-work/
Share on other sites

Sorry, theres no results.  I know the query works.  I've added the full code in case that helps.

 

And the website is www.bradleystokejudoclub.co.uk/test.php

 

Hope you can help  :-\

 

Thanks

 

<?php 

$conn = mysql_connect("80.94.196.33","gem","landseer") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('bssql',$conn) or trigger_error("SQL", E_USER_ERROR);

// FILTER BY PLAYERS NAME//
$sql="SELECT pname FROM pname ORDER BY pname"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

$id=$row["pname"]; 
$pname=$row["pname"]; 
$options.="<OPTION VALUE=\"$id\">".$pname.'</option>'; 
} 

// FILTER BY YEAR//
$sql1="SELECT year_full FROM year ORDER BY year_full"; 
$result1=mysql_query($sql1); 

$options1=""; 

while ($row1=mysql_fetch_array($result1)) { 

$id1=$row1["year_full"]; 
$year=$row1["year_full"]; 
$options1.="<OPTION VALUE=\"$id1\">".$year.'</option>'; 
} 
?>


<html>
<body>
<!-- FILTER BY PLAYER FORM -->
<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=pname> 
<OPTION VALUE=0>Choose 
<?=$options?> 
</SELECT> 
<input type="submit" name="submit" value="submit">
</FORM>
<!--FILTER BY YEAR FORM -->
<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=yearfull> 
<OPTION VALUE=0>Choose 
<?=$options1?> 
</SELECT> 
<input type="submit" name="submit1" value="submit1">
</FORM>


<?php
//DISPLAY FILTER BY PLAYER//
$pname=$_GET['pname'];
echo $pname;
if(isset($_GET['submit'])){


$sql="select pname, award, year_full
FROM pname, aw_result, award, year
WHERE pname.name_id=aw_result.pname_id
AND award.award_id=aw_result.award_id
AND year.year_id=aw_result.year_id
AND pname='$pname'
ORDER BY year.year_full DESC"; 
}
$pnameaw=mysql_query($sql);
while($row = mysql_fetch_array($pnameaw))
{
echo '<br />';
echo $row['award'] . '<br />';
echo $row['year_full'] . '<br />';
}

if(isset($_GET['submit'])) {

$sql="select pname, comp, place_name, year_full
from pname, comp, comp_result, place, year
where pname.name_id=comp_result.pname_id
and comp.comp_id=comp_result.comp_id
and place.place_id=comp_result.place_id
and year.year_id=comp_result.year_id
and pname='$pname'
order by year_full desc";
}
$pnamecomp=mysql_query($sql);
while($row = mysql_fetch_array($pnamecomp))
{
echo '<br />';
echo $row['comp'] . '<br />';
echo $row['place_name'] . '<br />';
echo $row['year_full'] . '<br />';
}


//DISPLAY FILTER BY YEAR//
$yearfull=$_GET['yearfull'];
echo $yearfull;
if(isset($_GET['submit1'])){


$sql4="select pname, award, year_full
FROM pname, award, aw_result, year
WHERE pname.name_id=aw_result.pname_id
AND award.award_id=aw_result.award_id
and year.year_id=aw_result.year_id
and year_full='$yearfull'
order by award;"; 
}
$yearaw=mysql_query($sql4);
while($row1 = mysql_fetch_array($yearaw))
{
echo '<br />';
echo $row1['pname'] . '<br />';
echo $row1['award'] . '<br />';
}

if(isset($_GET['submit1'])) {

$sql5="select pname, comp, place_name
FROM pname, comp, comp_result, place
WHERE pname.name_id=comp_result.pname_id
AND comp.comp_id=comp_result.comp_id
AND place.place_id=comp_result.place_id
and comp_year='$yearfull'
order by place.place_id;";
}
$yearcomp=mysql_query($sql5);
while($row1 = mysql_fetch_array($yearcomp))
{
echo '<br />';
echo $row1['place_name'] . '<br />';
echo $row1['pname'] . '<br />';
echo $row1['comp'] . '<br />';
}

?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/182834-why-wont-this-work/#findComment-965008
Share on other sites

try adding

or trigger_error(mysql_error());

after each of your queries. but one thing I noticed, in this query

 

$sql5="select pname, comp, place_name
FROM pname, comp, comp_result, place
WHERE pname.name_id=comp_result.pname_id
AND comp.comp_id=comp_result.comp_id
AND place.place_id=comp_result.place_id
and comp_year='$yearfull'
order by place.place_id;";

 

you seem to be columns that have the same name as tables

Link to comment
https://forums.phpfreaks.com/topic/182834-why-wont-this-work/#findComment-965013
Share on other sites

Apparently

No errors triggered, and is it a problem to have cols the same name as tables???

 

apparently not if no errors were triggers. If no errors were triggered, than the query is valid. Try tweaking your logic. Also, if you have PHPmyadmin, try entering the query directly into that and see if it returns anything

Link to comment
https://forums.phpfreaks.com/topic/182834-why-wont-this-work/#findComment-965037
Share on other sites

 

OK - I forgot to upload the file, hence no errors?! my bad.  Anyway, I dont think its the querys.  I did error_reporting (E_ALL); and now when I click submit for the pname box, I get this error:

 

PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 115 PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 136

 

But ... it doesn't do it when I click submit for the year box !?!?!?

 

Anybody??? Heres the full code again as I changed a few things:

 

<?php 

$conn = mysql_connect("80.94.196.33","gem","landseer") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('bssql',$conn) or trigger_error("SQL", E_USER_ERROR);

// FILTER BY PLAYERS NAME//
$sql="SELECT pname FROM pname ORDER BY pname"; 
$result=mysql_query($sql); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

$id=$row["pname"]; 
$pname=$row["pname"]; 
$options.="<OPTION VALUE=\"$id\">".$pname.'</option>'; 
} 

// FILTER BY YEAR//
$sql1="SELECT year_full FROM year ORDER BY year_full"; 
$result1=mysql_query($sql1); 

$options1=""; 

while ($row1=mysql_fetch_array($result1)) { 

$id1=$row1["year_full"]; 
$year=$row1["year_full"]; 
$options1.="<OPTION VALUE=\"$id1\">".$year.'</option>'; 
} 
?>


<html>
<body>
<!-- FILTER BY PLAYER FORM -->
<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=pname> 
<OPTION VALUE=0>Choose 
<?=$options?> 
</SELECT> 
<input type="submit" name="submit" value="submit">
</FORM>
<!--FILTER BY YEAR FORM -->
<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=yearfull> 
<OPTION VALUE=0>Choose 
<?=$options1?> 
</SELECT> 
<input type="submit" name="submit1" value="submit1">
</FORM>


<?php
//DISPLAY FILTER BY PLAYER//
$pname=$_GET['pname'];
echo $pname;
if(isset($_GET['submit'])){


$sql="select pname, award, year_full
FROM pname, aw_result, award, year
WHERE pname.name_id=aw_result.pname_id
AND award.award_id=aw_result.award_id
AND year.year_id=aw_result.year_id
AND pname='$pname'
ORDER BY year.year_full DESC"; 
}
$pnameaw=mysql_query($sql);
while($row = mysql_fetch_array($pnameaw))
{
echo '<br />';
echo $row['award'] . '<br />';
echo $row['year_full'] . '<br />';
}

if(isset($_GET['submit'])) {

$sql="select pname, comp, place_name, year_full
from pname, comp, comp_result, place, year
where pname.name_id=comp_result.pname_id
and comp.comp_id=comp_result.comp_id
and place.place_id=comp_result.place_id
and year.year_id=comp_result.year_id
and pname='$pname'
order by year_full desc";
}
$pnamecomp=mysql_query($sql);
while($row = mysql_fetch_array($pnamecomp))
{
echo '<br />';
echo $row['comp'] . '<br />';
echo $row['place_name'] . '<br />';
echo $row['year_full'] . '<br />';
}


//DISPLAY FILTER BY YEAR//
$yearfull=$_GET['yearfull'];
echo $yearfull;
if(isset($_GET['submit1'])){


$sql4="select pname, award, year_full
FROM pname, award, aw_result, year
WHERE pname.name_id=aw_result.pname_id
AND award.award_id=aw_result.award_id
and year.year_id=aw_result.year_id
and year_full='$yearfull'
order by award;" or trigger_error(mysql_error()); 

}
;
$yearaw=mysql_query($sql4);
while($row1 = mysql_fetch_array($yearaw))
{
echo '<br />';
echo $row1['pname'] . '<br />';
echo $row1['award'] . '<br />';
}

if(isset($_GET['submit1'])) {

$sql5="select pname, comp, place_name, year_full 
FROM pname, comp, comp_result, place, year 
WHERE pname.name_id=comp_result.pname_id 
AND comp.comp_id=comp_result.comp_id 
AND place.place_id=comp_result.place_id 
and year_full='2008' 
order by place.place_id;" or trigger_error(mysql_error());


}

$yearcomp=mysql_query($sql5);
while($row1 = mysql_fetch_array($yearcomp))
{
echo '<br />';
echo $row1['place_name'] . '<br />';
echo $row1['pname'] . '<br />';
echo $row1['comp'] . '<br />';
}

error_reporting(E_ALL);
?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/182834-why-wont-this-work/#findComment-965054
Share on other sites

Ok did that ... this is what gets returned when I click submit for pname (the firstbox) but still nothing happens when I press submit fro the second box!

 

PHP Warning: Wrong parameter count for trigger_error() in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 114 PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 115 PHP Warning: Wrong parameter count for trigger_error() in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 135 PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 136

 

Heres the updated code:

 

<?php 

$conn = mysql_connect("80.94.196.33","gem","landseer") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('bssql',$conn) or trigger_error("SQL", E_USER_ERROR);

// FILTER BY PLAYERS NAME//
$sql="SELECT pname FROM pname ORDER BY pname"; 
$result=mysql_query($sql) or trigger_error(); 

$options=""; 

while ($row=mysql_fetch_array($result)) { 

$id=$row["pname"]; 
$pname=$row["pname"]; 
$options.="<OPTION VALUE=\"$id\">".$pname.'</option>'; 
} 

// FILTER BY YEAR//
$sql1="SELECT year_full FROM year ORDER BY year_full"; 
$result1=mysql_query($sql1) or trigger_error(); 

$options1=""; 

while ($row1=mysql_fetch_array($result1)) { 

$id1=$row1["year_full"]; 
$year=$row1["year_full"]; 
$options1.="<OPTION VALUE=\"$id1\">".$year.'</option>'; 
} 
?>


<html>
<body>
<!-- FILTER BY PLAYER FORM -->
<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=pname> 
<OPTION VALUE=0>Choose 
<?=$options?> 
</SELECT> 
<input type="submit" name="submit" value="submit">
</FORM>
<!--FILTER BY YEAR FORM -->
<FORM action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<SELECT NAME=yearfull> 
<OPTION VALUE=0>Choose 
<?=$options1?> 
</SELECT> 
<input type="submit" name="submit1" value="submit1">
</FORM>


<?php
//DISPLAY FILTER BY PLAYER//
$pname=$_GET['pname'];
echo $pname;
if(isset($_GET['submit'])){


$sql="select pname, award, year_full
FROM pname, aw_result, award, year
WHERE pname.name_id=aw_result.pname_id
AND award.award_id=aw_result.award_id
AND year.year_id=aw_result.year_id
AND pname='$pname'
ORDER BY year.year_full DESC"; 
}
$pnameaw=mysql_query($sql) or trigger_error();
while($row = mysql_fetch_array($pnameaw))
{
echo '<br />';
echo $row['award'] . '<br />';
echo $row['year_full'] . '<br />';
}

if(isset($_GET['submit'])) {

$sql="select pname, comp, place_name, year_full
from pname, comp, comp_result, place, year
where pname.name_id=comp_result.pname_id
and comp.comp_id=comp_result.comp_id
and place.place_id=comp_result.place_id
and year.year_id=comp_result.year_id
and pname='$pname'
order by year_full desc";
}
$pnamecomp=mysql_query($sql) or trigger_error();
while($row = mysql_fetch_array($pnamecomp))
{
echo '<br />';
echo $row['comp'] . '<br />';
echo $row['place_name'] . '<br />';
echo $row['year_full'] . '<br />';
}


//DISPLAY FILTER BY YEAR//
$yearfull=$_GET['yearfull'];
echo $yearfull;
if(isset($_GET['submit1'])){


$sql4="select pname, award, year_full
FROM pname, award, aw_result, year
WHERE pname.name_id=aw_result.pname_id
AND award.award_id=aw_result.award_id
and year.year_id=aw_result.year_id
and year_full='$yearfull'
order by award;" or trigger_error(mysql_error()); 

}
;
$yearaw=mysql_query($sql4) or trigger_error();
while($row1 = mysql_fetch_array($yearaw))
{
echo '<br />';
echo $row1['pname'] . '<br />';
echo $row1['award'] . '<br />';
}

if(isset($_GET['submit1'])) {

$sql5="select pname, comp, place_name, year_full 
FROM pname, comp, comp_result, place, year 
WHERE pname.name_id=comp_result.pname_id 
AND comp.comp_id=comp_result.comp_id 
AND place.place_id=comp_result.place_id 
and year_full='2008' 
order by place.place_id;" or trigger_error(mysql_error());


}

$yearcomp=mysql_query($sql5) or trigger_error();
while($row1 = mysql_fetch_array($yearcomp))
{
echo '<br />';
echo $row1['place_name'] . '<br />';
echo $row1['pname'] . '<br />';
echo $row1['comp'] . '<br />';
}

error_reporting(E_ALL);
?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/182834-why-wont-this-work/#findComment-965072
Share on other sites

lol - no problem.  Ok this is what I get now...

 

PHP Notice: Query was empty in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 114 PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 115 PHP Notice: Query was empty in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 135 PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\test.php on line 136

 

 

Link to comment
https://forums.phpfreaks.com/topic/182834-why-wont-this-work/#findComment-965083
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.