Hi Pros, i m trying to lear php, i used txt editor & now i m using Drwamweaver but still unable to point out my mistakes. i have to read it again & again to find problem is there any other easy way to find out the problem. here is one example i tried but getting this error massage and here is coding
-Reading (and understanding) the error message. It even tells you the approximate line number. -Knowing the basic syntax. -A syntax highlighter (like dreamweaver) -If no error comes up, set this at the top of your script: error_reporting(E_ALL); ini_set('display_errors', '1'); PHP: EDIT: Your error says that there's probably a curly bracket missing }. The number always needs to be even. If it's odd, then you know you missed one somewhere.
Yeah bro it mention the line but u can see its saying 49 where "</html> written. i checked there is total 6 { }. no one is missing but still its very difficult to find error by this way thanks alot for your help
test your code regularly in small blocks, so if you do get an error you can track it down fairly easy. the line number reported for endings is nearly always wrong, you have to backtrack from that line number thats given until you find the error.
I tried your code and couldn't reproduce the error. At what point are you getting the error? Before entering any data or as soon as you open the page?
Try changing <? } ?> Code (markup): to <?php } ?> Code (markup): at the very end. There really is no easy way to debug code. As you gain experience you'll learn to more quickly pick out the simple mistakes. If you use a syntax highlighter you will gain an appreciation for which bits of your code should be which colour but it takes time.
Thank you very much for your responce. Streety you got it. as i wrote php it started working by the way i m also using WAMP server Thank you everybody, now i m using PHP Designer 2008 & its very helping
if($x == z){ echo "{"; } PHP: Odd You are right. To avoid such problem, you can practice writing the code without {} but would make it hard to understand later on. Peace,
<html> <head><title>Untitled Document</title></head> <body> <?php if (isset($_POST[posted])) { echo "<form method='POST' action='dynamic1.php'>"; for ($counter = 0; $counter < $_POST[number]; $counter ++) { $offset = $counter + 1; echo "<br>PLease enter the name of child number $offset<br>"; echo "<input name='child[]' type='text'>"; } echo "<br>Press the button to moe on<br>"; echo "<input type='submit' value='Next'>"; echo"<input type='hidden' name='posted01' value='true'></form>"; } else { if (isset($_POST[posted01])) { $count=0; echo "Your childrens names are: "; do { $childs_names = $_POST[child][$count]; echo"<br><b>$childs_names</b>"; $checkempty = $childs_names; $count = $count + 1; } while ($checkempty != ""); if ($count == 1) { echo "Not applicable"; } } ?> <hr> <form method="POST" action="dynamic1.php"> <input type="hidden" name="posted" value="true"> How many children do u have? <input type="text" name="number"> <br> <br> <input type="submit" value="Submit Number"> <br> </form> <?php } ?> </body> </html>
Do you know how to code in PHP? If you open curly brackets { for if or while/for loop statements than you must have to close curly brackets } What's difficult in it?
you buddies but here the problem was not curly brackets. i just missed writing "php" in that line <?php } ?> no everything is perfectly fine
Nobody is saying the line number is odd. If you go through all the code counting up the brackets the number you arrive at will be odd.