connect_error) {    die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM links WHERE code='$str'"; $result = $conn->query($sql); if ($result->num_rows > 0) {    // output data of each row    while($row = $result->fetch_assoc()) { //this is if the record was found        echo " Link Shortener
Fail!
Please try again, you won't see this error next time! "; //    } } elseif ($url == 'https://www.google.com/') { echo "Can't use that link, sorry!"; }else{ $servername = "localhost"; $username = "root"; $password = ""; $dbname = "l"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) {    die("Connection failed: " . mysqli_connect_error()); } $sql = "INSERT INTO links (code, link, hits) VALUES ('$str', '$url', '0')"; if (mysqli_query($conn, $sql)) {    echo(" Link Shortener
Success!
http://localhost/$str      "); } else {    echo "Error: " . $sql . "
" . mysqli_error($conn); } mysqli_close($conn); } } else {    echo(" Link Shortener
Fail!
Invalid URL "); } }else{ ?> Link Shortener
Link Shortener
Paste a link below and click shorten to make your long link shorter