Jump to content

[SOLVED] getting data from mysql


fantomel

Recommended Posts

Hello i'm trying to get some data from mysql but i run into a problem and i don't know how to fix it please can someone help me ?

 

 

 

function get_bottom_menu() {
    $query = "SELECT * FROM cms_pages WHERE active = 1 ORDER BY position";
    $result = mysql_query($query);
    while($check = mysql_fetch_array($result)) {
    echo "<a href="index.php?page=" . $check['page_id'] . ">" . ['link_name'] "."</a>";
    }


}

Link to comment
https://forums.phpfreaks.com/topic/148218-solved-getting-data-from-mysql/
Share on other sites

What does the error mean ? That you have closed your argument, but failed to close the echo statement...

 

Now where-o-where did I close that argument...hmm

echo "<a href="index.php?page=" . $check['page_id'] . ">" . ['link_name'] "."</a>";

You're getting close...

 

Your php is well formed, but you HTML is not...

http://www.w3schools.com/HTML/html_links.asp

 

You solve it in three ways:

1. escape the needed double qoutes inside your argument:

echo "<a href=\"index.php?page=" . $check['page_id'] . "\">" . $check['link_name'] "."</a>";

2. use single qoutes for your html:

echo "<a href='index.php?page=" . $check['page_id'] . "'>" . $check['link_name'] "."</a>";

3. use single qoutes for your echo statement:

echo '<a href="index.php?page=' . $check['page_id'] . '>' . $check['link_name'] '.'</a>';

 

At last: you may use variables in echo statements.

So probably the best would be:

echo "<a href=\"index.php?page=$check['page_id']\">$check['link_name']</a>";

 

Which should run fine...

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\config\config.php on line 31

for

echo "<a href=\"index.php?page=$check['page_id']\">$check['link_name']</a>";

and for the rest it gives the same error.. from the beginning.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.