jrodd32 Posted October 20, 2006 Share Posted October 20, 2006 [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] Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 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]<?phpfunction 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] Quote Link to comment Share on other sites More sharing options...
jrodd32 Posted October 20, 2006 Author Share Posted October 20, 2006 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 148however, there is a $ on line 148 which reads $coaches=init_coaches(&coach,$email,$sport); Quote Link to comment Share on other sites More sharing options...
jrodd32 Posted October 20, 2006 Author Share Posted October 20, 2006 Found that error, I am an idiot Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 [quote author=jrodd32 link=topic=112152.msg455138#msg455138 date=1161372775]Found that error, I am an idiot[/quote]lol... we all do it ;) Quote Link to comment Share on other sites More sharing options...
jrodd32 Posted October 20, 2006 Author Share Posted October 20, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.