0

Here I have my code when I test it out everything is working fine bedside that the result of MySQL connection isn't showing. I tried different thing but nothing seems working. I hoping that someone here will find and refer to where is issue that causing this database not to work.

Here is my code

<!DOCTYPE html>
<html lang="en">

<head>

    <title>Senior Projects Portal | Senior Advisors</title>
    <link rel="icon" href="logo.ico" type="image/x-icon">
    <link rel="shortcut icon" href="logo.ico" type="image/x-icon" />
    <meta name="description" content="Senior Project Portal">
    <meta name="keywords" content="Senior Project Portal">
    <meta name="author" content="Mr">
    <meta charset="UTF-8">

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/modern-business.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">


</head>

<body>

    <!-- Navigation -->
    <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="../index.php">Senior Projects Portal</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="index.php">Home</a>
                    </li>

                    <li class="active">
                        <a href="advisor.php">Senior Advisors</a>
                    </li>
                    <li>
                        <a href="pro-search.php">Search Projects</a>
                    </li>
                    <li>
                        <a href="project.php">Choose Project Topic</a>
                    </li>        
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <img class="img-responsive" src="img/user.png" style="width:22px; height:20px; "alt="">  
                </a>
            </li>    
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

    <!-- Page Content -->
    <div class="container">

        <!-- Page Heading/Breadcrumbs -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">List 
                    <small>of Senior Advisors</small>
                </h1>
                <ol class="breadcrumb">
                    <li><a href="index.php">Home</a>
                    </li>
                    <li class="active">Senior Advisors</li>
                </ol>
            </div>
        </div>
        <!-- /.row -->

        <!-- Content Row -->
        <div class="row">
            <div class="col-lg-12">
             <?php
            $cn=mysql_connect("localhost","aalkaabi","leatkifs") or die

            (mysql_error());
            mysql_select_db("aalkaabi",$cn) or die(mysql_error());
            $sql = "SELECT * FROM aalkaabi.Supervisor";
            $rs = mysql_query($sql) or die(mysql_error());

            $no=1;
            ?>


            <?
                while($row = mysql_fetch_array($rs)){?> 


                <div class="panel-group" id="accordion">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h4 class="panel-title">
                                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#<? echo $no?>"><? echo $row["0"]?></a>
                            </h4>
                        </div>
                        <div id="<? echo $no?>" class="panel-collapse collapse">
                            <div class="panel-body">

                            <h3><? echo $row["0"]?></h3>
                            <p>
                                <? echo $row["1"]?><br>
                            </p>

                            <p><i class="fa fa-envelope-o"></i> 
                                <abbr title="Email"><b>Email</abbr>:</b> <a href="mailto:<? echo $row["3"]?>"><?phpecho $row["2"]?></a>
                            </p>
                            <p><i class="fa fa-phone"></i> 
                                <abbr title="Phone"><b>Phone</abbr>:</b> <?echo $row["3"]?></p>
                            <p><i class="fa fa-clock-o"></i> 
                                <abbr title="Courses Taught"><b>Courses Taught</b></abbr>: <? echo $row["4"]?></p>

                            </div>
                        </div>
                    </div>
                    <!-- /.panel -->
                    <? 
                    $no = $no + 1;
            }mysql_free_result($rs);
            ?>
                </div>
                <!-- /.panel-group -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->

        <hr>

        <!-- Footer -->
        <footer>
            <div class="row">
                <div class="col-lg-12">
                    <p>Copyright &copy; <b style="color:#428bca;">Senior Projects Portal</b>, 2015.</p>
                </div>
            </div>
        </footer>

    </div>
    <!-- /.container -->

    <!-- jQuery Version 1.11.0 -->
    <script src="js/jquery-1.11.0.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

</body>

</html>
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • 6
    Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Apr 21 '15 at 21:53
  • 2
    "nothing seems working" could you be a little more descriptive –  Apr 21 '15 at 21:53
  • You could try `mysql_query($sql, $cn)`, but that's a guess at best. – William Isted Apr 21 '15 at 21:58
  • @Dagon I tried different tiltle but this the only one one is working – Zizou Al-kaabi Apr 21 '15 at 21:58
  • @Dagon what I meant the sql part – Zizou Al-kaabi Apr 21 '15 at 21:59

1 Answers1

0

Updated to mySqli at least: also found the error

$rs = mysqli_query($sql) or die(mysqli_error());

should be

$rs = mysqli_query($cn, $sql) or die(mysqli_error());

and the rest of the code:

<?php
$cn=mysqli_connect("localhost","aalkaabi","leatkifs") or die (mysqli_error());
mysqli_select_db("aalkaabi",$cn) or die(mysqli_error());
$sql = "SELECT * FROM aalkaabi.Supervisor";
$rs = mysqli_query($cn, $sql) or die(mysqli_error());
$no=1;
while($row = mysqli_fetch_array($rs)){?>
    <div class="panel-group" id="accordion">
        <div class="panel panel-default">
            <div class="panel-heading">
            <h4 class="panel-title">
            <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#<? echo $no; ?>"><? echo $row[0]; ?></a>
            </h4>
            </div>
            <div id="<? echo $no; ?>" class="panel-collapse collapse">
                <div class="panel-body">
                    <h3><? echo $row[0]; ?></h3>
                    <p><? echo $row[1]; ?><br></p>
                    <p><i class="fa fa-envelope-o"></i> 
                    <abbr title="Email"><b>Email</abbr>:</b> <a href="mailto:<? echo $row[3]; ?>"><?phpecho $row[2]; ?></a>
                    </p>
                    <p><i class="fa fa-phone"></i> 
                    <abbr title="Phone"><b>Phone</abbr>:</b> <?echo $row[3]; ?></p>
                    <p><i class="fa fa-clock-o"></i>
                    <abbr title="Courses Taught"><b>Courses Taught</b></abbr>: <? echo $row[4]; ?></p>
                </div>
            </div>
        </div>
    </div>
    <? 
    $no = $no++;
}
mysqli_free_result($rs);
?>
Xander Luciano
  • 3,753
  • 7
  • 32
  • 53