1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Parse error

Discussion in 'HTML & Website Design' started by goalseeker, Nov 15, 2012.

  1. #1
    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
     
    goalseeker, Nov 15, 2012 IP
  2. maneetpuri

    maneetpuri Active Member

    Messages:
    152
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Well, you have to use semicolon ; instead of comma (,) at the end of line 12.
     
    maneetpuri, Nov 15, 2012 IP
  3. Dev-D

    Dev-D Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    also on line 20 you would like to correct it to
    $menuDisplay='<a href="index.php?pid=' . $pid .'">' .$linklabel . '</a><br />';
     
    Dev-D, Nov 15, 2012 IP
  4. Dev-D

    Dev-D Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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
     
    Dev-D, Nov 15, 2012 IP
  5. goalseeker

    goalseeker Greenhorn

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    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
     
    goalseeker, Nov 16, 2012 IP
  6. goalseeker

    goalseeker Greenhorn

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    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
     
    Last edited: Nov 16, 2012
    goalseeker, Nov 16, 2012 IP
  7. Dev-D

    Dev-D Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    nusphere link

    http://www.nusphere.com/
     
    Dev-D, Nov 16, 2012 IP
  8. Dev-D

    Dev-D Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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
     
    Dev-D, Nov 16, 2012 IP
  9. goalseeker

    goalseeker Greenhorn

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #9
    Many thanks for the link I have downloaded trial version and will work on that.

    cheers
     
    goalseeker, Nov 16, 2012 IP
  10. goalseeker

    goalseeker Greenhorn

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #10
    Many thanks for taking time out to help in this way it is appreciated.

    I will change my coding to suit.
    cheers
     
    goalseeker, Nov 16, 2012 IP