Jump to content

PHP Hyperlinks


ellchr3

Recommended Posts

Hello.  I'm having trouble with using hyperlinks in PHP.  I've found several things online about using the print or echo command but for some reason it only gives the link as text and not an actual link.  I'm very new to PHP so please be gentle :)

 

<?php

$con = mysql_connect("localhost","xxxxx","xxxxx");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("addresses", $con);

 

$sql="INSERT INTO addresses (first_name, last_name, extra_info, address, city, state, zip)

VALUES

('$_POST[first_name]','$_POST[last_name]','$_POST[extra_info]','$_POST[address]','$_POST[city]','$_POST[state]','$_POST[zip]')";

 

if (!mysql_query($sql,$con))

  {

  die('Error: ' . mysql_error());

  }

echo "1 record added";

echo "<a ref="http://localhost/index.html">Click here to enter another record</a>";

mysql_close($con)

?>

Link to comment
https://forums.phpfreaks.com/topic/253022-php-hyperlinks/
Share on other sites

In the code have very many errors.

I've recommended you alter it so:

<?php
$con = mysql_connect("localhost","xxxxx","xxxxx") or die('Could not connect: ' . mysql_error());
mysql_select_db("addresses", $con);

$sql = "INSERT INTO `addresses` (`first_name`, `last_name`, `extra_info`, `address`, `city`, `state`, `zip`)
        VALUES ('" . mysql_real_escape_string($_POST['first_name']) . "', '" . mysql_real_escape_string($_POST['last_name']) . "',
                '" . mysql_real_escape_string($_POST['extra_info']) . "', '" . mysql_real_escape_string($_POST['address'])   . "',
                '" . mysql_real_escape_string($_POST['city'])       . "', '" . mysql_real_escape_string($_POST['state'])     . "',
                '" . mysql_real_escape_string($_POST['zip'])        . "')";

mysql_query($sql,$con) or die('Error: ' . mysql_error());

echo "1 record added";
echo '<a ref="http://localhost/index.html">Click here to enter another record</a>';

mysql_close($con);

?>

Link to comment
https://forums.phpfreaks.com/topic/253022-php-hyperlinks/#findComment-1297208
Share on other sites

Even with changing the single and double quotes to the way you specified, Adib, it still doesn't create the hyperlink.  Could it be something with the web server setup?  I installed Xampp so I thought it configured everything properly. 

 

I also made the modifications that Winstons suggested and still get the same results.  It doesn't create the hyperlink, only text. 

 

Thanks for your help so far guys.  Any other suggestions? :)

Link to comment
https://forums.phpfreaks.com/topic/253022-php-hyperlinks/#findComment-1298135
Share on other sites

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.