suttercain Posted February 7, 2007 Share Posted February 7, 2007 I am reading a How to PHP book and I was told to create the following script: <?php function addNums( $firstnum, $secondnum; { $result = $firstnum + $secondnum ) return $result;11: } print addNums(3,5); ?> This should just add 3 + 5 and give the result of 8, instead I get the following error: Parse error: syntax error, unexpected ';', expecting '{' in /home/superman/public_html/test.php on line 2 Is this book wrong yet again? Thanks in advance. Shannon Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/ Share on other sites More sharing options...
alpine Posted February 7, 2007 Share Posted February 7, 2007 return $result;11: should be only return $result; Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179361 Share on other sites More sharing options...
Caesar Posted February 7, 2007 Share Posted February 7, 2007 return $result;11: should be only return $result; And.... function addNums( $firstnum, $secondnum; Should be: <?php function addNums( $firstnum, $secondnum) ?> Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179362 Share on other sites More sharing options...
alpine Posted February 7, 2007 Share Posted February 7, 2007 yah, good spot Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179363 Share on other sites More sharing options...
suttercain Posted February 7, 2007 Author Share Posted February 7, 2007 Cool That worked. Thanks... man this "Teach Yourself PHP in 24 Hours" contains a lot of errors. Anyone know of some great starter books or tutorials? Also, since taking out the 11: the error was on line 5, so why was I being told the error was on line 2? I am new to this so stick with me! Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179366 Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 The first error was on line 2, The ; in place of ) It stopped at that error before reaching the one on 5. Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179374 Share on other sites More sharing options...
roopurt18 Posted February 7, 2007 Share Posted February 7, 2007 Are those typos actually in the book? Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179376 Share on other sites More sharing options...
suttercain Posted February 7, 2007 Author Share Posted February 7, 2007 Yup. Both of those errors are in the book... kind of makes it hard to learn. But the book was published in 2001 so I don't know. I checked their site for a "known errors" page but they didn't have one Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179427 Share on other sites More sharing options...
Ninjakreborn Posted February 7, 2007 Share Posted February 7, 2007 www.google.com "Safari Bookshelf" 39.99 per month, for unlimited access. You will never be the same again, or will never need access to another book again. Quote Link to comment https://forums.phpfreaks.com/topic/37508-parse-error-syntax-error-unexpected-expecting/#findComment-179449 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.