williamh69 Posted March 18, 2014 Share Posted March 18, 2014 hi guys i have the following db table called topnavigation id name url title this is the code to get the navigation from mysql <?php include("mylibrary/login.php"); $sql = mysql_query("SELECT * FROM topnavigation"); while($row = mysql_fetch_array($sql)){ $id = $row['id']; $name = $row['name']; $url = $row['url']; $title = $row['title']; echo"<li>"; echo"<a href='$url' title='$title'>$name</a>"; echo"</li>"; } ?> But i have this error: atal error: Cannot redeclare login() (previously declared in C:\wamp\www\sparklenshine\mylibrary\login.php:3) in C:\wamp\www\sparklenshine\mylibrary\login.php on line 7 thank your for help Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 18, 2014 Share Posted March 18, 2014 your code is trying to include the mylibrary\login.php file multiple times. you would need to find out why and make sure you are only including it once. generally library files your code needs are included near the start of your main code file. Quote Link to comment Share on other sites More sharing options...
maxxd Posted March 18, 2014 Share Posted March 18, 2014 Looks like the problem is not with the quoted code, but that you've got two login() functions in one of the files or you're importing mylibrary\login.php twice. Try include_once() or require_once instead of include(). Also (has nothing to do with the issue at hand, but needs to be said), switch from the mysql library to mysqli() or pdo() - the mysql lib has been deprecated for quite a while and will be removed soon if it hasn't been already. Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted March 18, 2014 Share Posted March 18, 2014 Good afternoon William, Could you please include the contents from the file mylibrary/login.php as this is where your error is located. Cheers! Quote Link to comment Share on other sites More sharing options...
williamh69 Posted March 18, 2014 Author Share Posted March 18, 2014 <?php function login() { $con = mysql_connect("localhost", "xxxx", "xxxx") or die('Could not connect to server'); mysql_select_db("xxxx", $con) or die('Could not connect to database'); } ?> this is the loging function.... from file called mylibrary Quote Link to comment 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.