Jump to content

Not valid result resource


jrodd32

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]
Link to comment
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]
Link to comment
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);
Link to comment
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
Link to comment
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.