-1

I am faceing the problem, that my $link is not displayed. If I insert the lines described below, the site won't load anymore. The following code works properly.

<?php

    $mysqli = new mysqli('host', 'name', 'psw', 'db');
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    if ($result = $mysqli->query("SELECT user_level FROM users WHERE user_level = 1 ")) {

        /* determine number of rows result set */
        $row_cnt = $result->num_rows;

        printf("Result set has %d rows.\n", $row_cnt);
        }

    if ($result->num_rows == 1) {
    printf ("Adminpanel");

        $result->close();


    }

    /* close connection */
    $mysqli->close();
    ?>

When I add this line

$link = 'AdminLayout.php';
    printf ("<a href="' .$link. '">Adminpanel </a>");

instead of

printf ("Adminpanel");

nothing works anymore. What have I done wrong?

pr0cz
  • 509
  • 7
  • 22

2 Answers2

1

you have a syntax error

printf ("<a href="' .$link. '">Adminpanel </a>");

should be

printf ("<a href='" .$link. "'>Adminpanel </a>");

you have your quotation in wrong order.

Btw. if you get a blank page, you might turn error reporting on. Put this at the beginning of your script.

ini_set('display_errors', 1);
error_reporting(E_ALL);
Ben
  • 673
  • 3
  • 11
1

try this: its a quotes problem. if you need double quotes"" with href try with single quotes' at start and end.

$link = 'AdminLayout.php';
    printf ('<a href="' .$link. '">Adminpanel </a>');
prasanth
  • 22,145
  • 4
  • 29
  • 53