Hi I am going first to ask for patience as well as help I am a silver surfer and am trying to learn mySQL and phpmyadmin. I have written siome code but have got the following error and I cannot see the problem wonder if someone would kindly help please. Code as written error message received: Parse error: syntax error, unexpected T_VARIABLE in /home/telsave/public_html/freudzstock/index.php on line 12 Possibly my old eyes have missed something. 11.//Build Main Navigation menu and gather page data here 12.$sqlCommand = "SELECT id, linklabel FROM pages ORDER BY pageorder ASC", 13.$query=mysqli_query($myConnection, $sqlCommand) or die(mysqli_error()); 14. 15.$menuDisplay=""; 16.while($row=mysqli_fetch_array($query)){ 17. $pid=$row["id"]; 18. $linklabel=$row["linklabel"]; 19. 20. $menuDisplay='a href=index.php?pid=' . $pid .'">' .$linklabel . '</a><br />'; 21. 22.} 23.mysqli_free_result($query); 24.//mysqli_close($myConnection), Thank you
also on line 20 you would like to correct it to $menuDisplay='<a href="index.php?pid=' . $pid .'">' .$linklabel . '</a><br />';
also if you are making a menu dynamically i suggest you make it with ul and li structure as it is more seo friendly for common syntax errors use a editors like nu speare which highlight them
Many thanks for taking the time out to try to help, I have changed the coding as suggested to $sqlCommand = "SELECT id, linklabel FROM pages ORDER BY pageorder ASC"; $query=mysqli_query($myConnection, $sqlCommand) or die(mysqli_error()); unfortunately the same error occurs Parse error: syntax error, unexpected T_VARIABLE in /home/telsave/public_html/freudzstock/index.php on line 12 if you have the time to try to help further I would be grateful cheers
Hi Many thanks for taking time out to try to help I have changed line 20 as you suggested, but, as you can see above I do have the same error. I am interested in nu speare but when I Google it I get information regarding North Eastern University, do you have a link by any chance? I shall use ul and li when I get the error sorted as you suggest it does make the coding more user friendly cheers
your codewas not connecting to server correctly heres the one corrected and tested by me change the database parameters $myConnection = new mysqli("localhost","username","password",'databasename'); $sqlCommand = "SELECT id, linklabel FROM pages ORDER BY pageorder ASC"; $query=mysqli_query($myConnection, $sqlCommand) or die(mysqli_error($myConnection)); $menuDisplay=''; while($row=mysqli_fetch_array($query)){ $pid=$row["id"]; $linklabel=$row["linklabel"]; $menuDisplay.='<a href="index.php?pid=' . $pid .'">' .$linklabel . '</a><br />'; } mysqli_free_result($query); mysqli_close($myConnection); echo $menuDisplay; hope it helps
Many thanks for taking time out to help in this way it is appreciated. I will change my coding to suit. cheers