Jump to content


Photo

Not valid result resource


  • Please log in to reply
5 replies to this topic

#1 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 October 2006 - 05:49 PM

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());
}

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

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>');
    }


#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 20 October 2006 - 06:16 PM

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:
<?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)) {

}
?>

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 October 2006 - 07:12 PM

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);


#4 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 October 2006 - 07:32 PM

Found that error, I am an idiot

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 20 October 2006 - 07:33 PM

Found that error, I am an idiot

lol... we all do it ;)
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 jrodd32

jrodd32
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 October 2006 - 07:49 PM

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.

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;
}
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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users