Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.