Languages :: PHP :: error correction for lornajane |
|||
| By: bartonjo2 |
Date: 17/09/2003 00:00:00 |
Points: 25 | Status: Answered Quality : Excellent |
|
for some reason i ge this error: You have an error in your SQL syntax near '' at line 1 on this page (srankedit.php): <?php //if ($lid and $dwmx12345 == "1852ujh") { include("connect.php"); $i=0; // a counter to keep track of how many badges have been shown // check out which badges he has $troop = mysql_query("select * from data where id=$id") or die(mysql_error()); // pull all the scouts' records out $scout = mysql_fetch_assoc($troop); $scouts_ranksa = explode('*',$scout['Requirements']); // $scouts_badges is now an array of what badges the scout has $result = mysql_query("SELECT `Requirements`, `rank` FROM `data` WHERE name='$scout_n'",$db); while ($scoutdata = mysql_fetch_array($result, $db)) { $rank = $scoutdata["rank"]; $scout_rank_requirements = $scoutdata["Requirements"]; } if ($rank == "Join") { $working_on = "Tenderfoot"; } if ($rank == "Tenderfoot") { $working_on = "Second Class"; } if ($rank == "Second Class") { $working_on = "First Class"; } if ($rank == "First Class") { $working_on = "Star"; } if ($rank == "Star") { $working_on = "Life"; } if ($rank == "Life") { $working_on = "Eagle"; } if ($rank == "Eagle") { $working_on = "Bronze Palm"; } if ($rank == "Bronze Palm") { $working_on = "Gold Palm"; } if ($rank == "Gold Palm") { $working_on = "Silver Palm"; } ?> <form name="rankreqs" method="post" action="rank_post.php"> <table border=0> <tr><td valign="top"> <?php $i=0; // a counter to keep track of how many badges have been shown $resultset = mysql_query("select * from ranks where Rank='$working_on'") or die(mysql_error()); while($advancement = mysql_fetch_assoc($resultset)) { echo("<label for=\"".$advancement['code']."\"><input name=\"rank_requirements[]\" value=\"".$advancement['code']."\" type=\"checkbox\" id=\"".$advancement['code']."\""); if(in_array($advancement['code'], $scouts_ranksa)) echo("checked"); // ticks the box if this scout has it echo(">".$advancement['name']."</label> \n"); $i++; if($i == 41 or $i == 82) echo("\t</td>\n\t<td valign=\"top\">"); } ?> </td></tr> </table> </form> <?php // } //else { //echo "<title>Authorization Required</title>"; //echo "You are not Authorized to View this Page"; //} ?> I wonder though if it has anything to do with this link on its previous editing page: <a href="index.php?PAGE=20&scout_n=<?php echo "$scoutn"."&sid="."$id"; ?>">Click Here to Edit <?php echo $scoutn."'s"; ?> Progress on Their Current Rank </a> |
|||
| By: VGR | Date: 17/09/2003 17:47:00 | Type : Comment |
|
| 1) make it : <?php echo <<<EOS <a href="index.php?PAGE=20&scout_n=$scoutn&sid=$id">Click Here to Edit $scoutn's Progress on Their Current Rank </a> EOS; ?> 2) I don't get the "You have an error in your SQL syntax near '' at line 1" |
|||
| By: bartonjo2 | Date: 17/09/2003 17:49:00 | Type : Comment |
|
| well i dont know why it does that, that is why I am asking |
|||
| By: VGR | Date: 17/09/2003 17:57:00 | Type : Comment |
|
| please fix this : ("SELECT `Requirements`, `rank` FROM `data` WHERE name='$scout_n'",$db into ("SELECT Requirements, rank FROM data WHERE name='$scout_n';",$db |
|||
| By: bartonjo2 | Date: 17/09/2003 18:10:00 | Type : Comment |
|
| i still get same error |
|||
| By: VGR | Date: 17/09/2003 18:15:00 | Type : Comment |
|
| well, line 1 isn't even an SQL query, so the error is meaningless |
|||
| By: bartonjo2 | Date: 17/09/2003 19:08:00 | Type : Comment |
|
| but then how do i get the content to display? |
|||
| By: LornaJane | Date: 18/09/2003 21:18:00 | Type : Comment |
|
| Hi bartonjo2, do you know which mysql query it is happening in? How about you change your lines with the query in so the error message identifies which is which, then we can narrow it down a bit. Die() just tells the script to send a message and stop trying to execute. so instead of die(mysql_error()) you can do die("query1".mysql_error()) I'm looking at a suspect query, it's this line: $result = mysql_query("SELECT `Requirements`, `rank` FROM `data` WHERE name='$scout_n'",$db); I think you want something along the lines of $result = mysql_query("select requirements, rank from data where name=$scout_n") or die("query2".mysql_error()); Once you know which query is giving you the problem, then copy the line which does mysql_query() and instead of querying what is inside that set of brackets, echo it to the screen. Post it here if you can't figure out the problem. I'll be online all day (GMT) so will do my best to help :) |
|||
| By: bartonjo2 | Date: 18/09/2003 21:20:00 | Type : Comment |
|
| heres my latest code <?php //if ($lid and $dwmx12345 == "1852ujh") { include("connect.php"); $i=0; // a counter to keep track of how many badges have been shown // check out which badges he has $troop = mysql_query("select * from data where id=$sid"); // or die(mysql_error()); // pull all the scouts' records out $scout = mysql_fetch_assoc($troop); $scouts_ranksa = explode('*',$scout['Requirements']); // $scouts_badges is now an array of what badges the scout has $result = mysql_query("select requirements, rank from data where name='$scout_n'") or die("query2".mysql_error()); while ($scoutdata = mysql_fetch_array($result, $db)) { $rank = $scoutdata["rank"]; $scout_rank_requirements = $scoutdata["Requirements"]; } if ($rank == "Join") { $working_on = "Tenderfoot"; } if ($rank == "Tenderfoot") { $working_on = "Second Class"; } if ($rank == "Second Class") { $working_on = "First Class"; } if ($rank == "First Class") { $working_on = "Star"; } if ($rank == "Star") { $working_on = "Life"; } if ($rank == "Life") { $working_on = "Eagle"; } if ($rank == "Eagle") { $working_on = "Bronze Palm"; } if ($rank == "Bronze Palm") { $working_on = "Gold Palm"; } if ($rank == "Gold Palm") { $working_on = "Silver Palm"; } echo $working_on; ?> <form name="rankreqs" method="post" action="rank_post.php"> <table border=0> <tr><td valign="top"> <?php $i=0; // a counter to keep track of how many badges have been shown $resultset = mysql_query("select * from ranks where Rank='$working_on'"); //or die(mysql_error()); while($advancement = mysql_fetch_assoc($resultset)) { echo("<label for=\"".$advancement['code']."\"><input name=\"rank_requirements[]\" value=\"".$advancement['code']."\" type=\"checkbox\" id=\"".$advancement['code']."\""); if(in_array($advancement['code'], $scouts_ranksa)) echo("checked"); // ticks the box if this scout has it echo(">".$advancement['name']."</label> \n"); $i++; if($i == 41 or $i == 82) echo("\t</td>\n\t<td valign=\"top\">"); } ?> </td></tr> </table> </form> <?php // } //else { //echo "<title>Authorization Required</title>"; //echo "You are not Authorized to View this Page"; //} ?> |
|||
| By: bartonjo2 | Date: 18/09/2003 21:26:00 | Type : Comment |
|
| just made some changes here is the latest code: <?php //if ($lid and $dwmx12345 == "1852ujh") { include("connect.php"); $i=0; // a counter to keep track of how many badges have been shown // check out which badges he has $troop = mysql_query("select * from data where id=$sid"); // or die(mysql_error()); // pull all the scouts' records out $scout = mysql_fetch_assoc($troop); $scouts_ranksa = explode('*',$scout['Requirements']); // $scouts_badges is now an array of what badges the scout has $result = mysql_query("select requirements, rank from data where name='$scout_n'") or die("query2".mysql_error()); while ($scoutdata = mysql_fetch_array($result, $db)) { $rank = $scoutdata["rank"]; $scout_rank_requirements = $scoutdata["Requirements"]; } if ($rank == "Join") { $working_on = "Tenderfoot"; } if ($rank == "Tenderfoot") { $working_on = "Second Class"; } if ($rank == "Second Class") { $working_on = "First Class"; } if ($rank == "First Class") { $working_on = "Star"; } if ($rank == "Star") { $working_on = "Life"; } if ($rank == "Life") { $working_on = "Eagle"; } if ($rank == "Eagle") { $working_on = "Bronze Palm"; } if ($rank == "Bronze Palm") { $working_on = "Gold Palm"; } if ($rank == "Gold Palm") { $working_on = "Silver Palm"; } // echo $working_on; ?> <form name="rankreqs" method="post" action="rank_post.php"> <table border=0> <tr><td valign="top"> <?php $i=0; // a counter to keep track of how many badges have been shown $resultset = mysql_query("select * from ranks where Rank='$working_on'") or die(mysql_error()); while($advancement = mysql_fetch_assoc($resultset)) { echo("<label for=\"".$advancement['code']."\"><input name=\"rank_requirements[]\" value=\"".$advancement['code']."\" type=\"checkbox\" id=\"".$advancement['code']."\""); if(in_array($advancement['code'], $scouts_ranksa)) echo("checked"); // ticks the box if this scout has it echo(">".$advancement['requirement']."</label> \n"); $i++; if($i == 41 or $i == 82) echo("\t</td>\n\t<td valign=\"top\">"); } ?> </td></tr> </table> </form> <?php // } //else { //echo "<title>Authorization Required</title>"; //echo "You are not Authorized to View this Page"; //} ?> |
|||
| By: LornaJane | Date: 18/09/2003 21:47:00 | Type : Comment |
|
| at first glance that looks ok, does it work? |
|||
| By: bartonjo2 | Date: 18/09/2003 22:02:00 | Type : Comment |
|
| no it displays a blank page |
|||
| By: LornaJane | Date: 18/09/2003 22:19:00 | Type : Comment |
|
| sorry am just rushing off somewhere but I will get back to you. Try putting an echo() statement first on the page, see if you can see that. Then try some further down if you can, see if you can narrow down where the execution stops. It seems strange that you don't even get error messages Oh and view your source, see if anything at all is being out put. Let me know how you get on and I'll get back to you when I can |
|||
| By: bartonjo2 | Date: 18/09/2003 22:29:00 | Type : Comment |
|
| can you maybe rewrite the page!! thanks |
|||
| By: bartonjo2 | Date: 18/09/2003 22:59:00 | Type : Comment |
|
| i can echo variables and they appear but not the database retrieved info |
|||
| By: bartonjo2 | Date: 18/09/2003 23:09:00 | Type : Comment |
|
| found the problem! I was using my own profile and I am an eagle scout so it was trying to find eagle requirements but i havent added them to the db yet |
|||
| By: VGR | Date: 18/09/2003 23:17:00 | Type : Answer |
|
| huh huh huh 8-)) |
|||
| By: bartonjo2 | Date: 19/09/2003 21:02:00 | Type : Comment |
|
| sometimes my mistakes are so obvious it amazes me i did not notice earlier |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








