Jump to content

Archived

This topic is now archived and is closed to further replies.

jrodd32

Not valid result resource

Recommended Posts

[code]
function init_coaches($coach,$email,$sport)
{
  $db = @mysql_connect('*', '*','*') or die ('Unable to Connect');
  mysql_select_db('*',$db) or die ("Unable to select database");
  $query = "SELECT $coach, school, $email, address1, address2, city, zip, phone, athphone, faxphone FROM KHSAA_Schools WHERE    member=\"T\" and $sport=\"T\" order by school";
  $coaches = mysql_query($query) or die ("Error in query: $query".mysql_error());
}
[/code]

That is obviously my query.  Here is the line with the error

[code]
while($row=mysql_fetch_assoc($coaches)) //Line that contains error
    {
      printf('%-25s ',$row[$coach]);
      printf('%-30s ',$row[school]);
      printf('%-20s ',$row[city]);
      printf('%-20s ',$row[phone]);
      printf('%-20s ',$row[faxphone]);
      printf('%-50s ',$row[$email]);
      print('<br>');
    }
[/code]

Share this post


Link to post
Share on other sites
your query is within a function, so the variable $coaches is not available for you to use in your while() loop. you'll need to return that variable for it to be used:
[code]
<?php
function init_coaches($coach,$email,$sport)
{
  $db = @mysql_connect('*', '*','*') or die ('Unable to Connect');
  mysql_select_db('*',$db) or die ("Unable to select database");
  $query = "SELECT $coach, school, $email, address1, address2, city, zip, phone, athphone, faxphone FROM KHSAA_Schools WHERE    member=\"T\" and $sport=\"T\" order by school";
  $coaches = mysql_query($query) or die ("Error in query: $query".mysql_error());
  return $coaches;
}

$coaches = init_coaches($coach,$email,$sport);
while ($row = mysql_fetch_assoc($coaches)) {

}
?>
[/code]

Share this post


Link to post
Share on other sites
that took care of that error but caused

Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in /home/httpd/vhosts/khsaa.org/subdomains/admin/httpdocs/jerrod/coaches/tool_kit.inc on line 148

however, there is a $ on line 148 which reads

  $coaches=init_coaches(&coach,$email,$sport);

Share this post


Link to post
Share on other sites
[quote author=jrodd32 link=topic=112152.msg455138#msg455138 date=1161372775]
Found that error, I am an idiot
[/quote]
lol... we all do it ;)

Share this post


Link to post
Share on other sites
Now the mysql.error() is telling me i have an error near    ="T" (notice the space), there is supposed to be $sport in there.  However, if I tell it to print $sport it will print the proper info.

[code]
function init_coaches($coach,$email,[b]$sport[/b])
{
  $db = @mysql_connect('localhost', 'khsaa','executivedrive') or die ('Unable to Connect');
  mysql_select_db('Scoreboard',$db) or die ("Unable to select database");
  $query = "SELECT $coach, school, $email, address1, address2, city, zip, phone, athphone, faxphone FROM KHSAA_Schools WHERE member=\"T\" and [b]$sport[/b]=\"T\" order by school";
  $coaches = mysql_query($query) or die ("Error in query: $query".mysql_error());
  return $coaches;
}
[/code]
error:
Error in query: SELECT xcgcoach, school, xcgcoemail, address1, address2, city, zip, phone, athphone, faxphone FROM KHSAA_Schools WHERE member="T" and (notice the space) ="T" order by schoolYou have an error in your SQL syntax near '="T" order by school' at line 1

Share this post


Link to post
Share on other sites

×

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.