Jump to content

Recommended Posts

hi does any one know how to insert a html code like this

<a href="http://rover.ebay.com/rover/1/710-5232-2978-8/1?aid=5834748&pid=2804964" target="_blank" onmouseover="window.status='http://www.ebay.co.uk';return true;" onmouseout="window.status=' ';return true;">
<img src="http://www.tqlkg.com/image-2804964-5834748" width="120" height="30" alt="Click here to buy & sell on eBay!" border="0"/></a>

into a sql table via a php form?

 

i'm really stuck... ???

 

Thanks in advance! :D

  • Replies 58
  • Created
  • Last Reply

Top Posters In This Topic

You have to be more specific, and need to elaborate more on your questions. You are giving the viewers of your thread or those who wan't to help limited information on your problem....

 

I am guessing you want to add that HTML code to your Mysql using PHP ? correct?

i would assume

<?php
$avar = '<a href="http://rover.ebay.com/rover/1/710-5232-2978-8/1?aid=5834748&pid=2804964" target="_blank" onmouseover="window.status=\'http://www.ebay.co.uk\';return true;" onmouseout="window.status=' ';return true;">';
$avar .= '<img src="http://www.tqlkg.com/image-2804964-5834748" width="120" height="30" alt="Click here to buy & sell on eBay!" border="0"/></a>'

$SQL = "INSERT INTO `table` SET field = '$avar';";
?>

 

hi guys,

 

sorry i'll explain.

 

the links are all saved in a table.

 

they are then all pulled out and arranged nicely in a grid on the page using some adapted code i found on here.

 

then with the submit button it saves the username (from a cookie) and the link into another table

 

ready to be pull on to the users login page

 

the problem i'm having is that when it saves it into the 2nd table, it only inserts

 

<a href="http://rover.ebay.com/rover/1/710-5232-2978-8/1?aid=5834748&pid=2804964" target="_blank" onmouseover="window.status=

 

rather than the full

 

<a href="http://rover.ebay.com/rover/1/710-5232-2978-8/1?aid=5834748&pid=2804964" target="_blank" onmouseover="window.status='http://www.ebay.co.uk';return true;" onmouseout="window.status=' ';return true;">
<img src="http://www.tqlkg.com/image-2804964-5834748" width="120" height="30" alt="Click here to buy & sell on eBay!" border="0"/></a>

sorry

 

yes you guys are correct that's what i want to do,

 

but it's confusing things as i'm pulling them out of a table to start with.

 

i would post the current code.

 

but my last post got deleted for double posting, and the previous post is now out of date

due to the way this code is working i'll have to say:

<?php

$_POST['user2'] = mysql_real_escape_string(nl2br(addslashes($_POST['user2'])));

?>

 

or

 


<?php

$_POST['user2'] = htmlspecialchars($_POST['user2'], ENT_QUOTES);

?>

 

that's ok.... isn't it???

Thankyou soo much,

 

this really means alot!!

 

see page here: http://www.everyonlinestore.co.uk/change_password.php          (ignore the name)

 

you'll get an error as you're not logged in, but feel free to click the banner and sign up. then go back to the page and refresh

i obviously haven't gone live yet :D

 

page of links with submit function

 

<?php

$mysite_username = $_COOKIE["mysite_username"];

$conn = mysql_connect($server, $db_user, $db_pass)
or die ("could not connect to mysql");  #Connect to mysql
$rs = mysql_select_db( $database, $conn )
or die ("Could not select database"); #select database 

$sql = "Select link FROM links";  //pull the users from the table

$result= mysql_query($sql)
or die(" Could not add style facts");

echo "<table align=center border=1>";        // display the users in table
$c = 0;
while($row = mysql_fetch_array($result)) { 
  $user2 = $row['link'];
  if($c%5 == 0) echo "<tr height=\"200px\">"; // If the counter has ticked 6 times, start a new row.
echo "<td><FORM action='addlinks.php' method='post'><p><input type=HIDDEN name='user' value='$mysite_username'></p><p align=center><input type=hidden name='user2' value='$user2'></p><p align=center>rating script here</p><p align=center><input type=submit></p></form>";

  if($c%5 == 4) echo "</tr>"; // If we're drawing the 6th pic, end this row.
  $c++;
}
if($c%5 != 4) echo "</tr>"; // If there isn't a number of pics divisible by 6, end the row
echo "</table>"; // end the table


?>

 

Add links php

 

<?php

// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());

// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());

// insert the data
$insert = mysql_query("insert into memberlinks values ('".$_POST['user']."', '".$_POST['user2']."')")
or die("Could not insert data because ".mysql_error());

// print a success message
echo "Your link has been added!<br>"; 
echo "Now you can <a href=change_password.php>add another link</a>"; 

?>

 

Thankyou!!

 

add link should look like this

<?php

// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error());

// select the database
mysql_select_db($database) or die ("Could not select database because ".mysql_error());

// insert the data
$user = mysql_real_escape_string($_POST['user']);
$user2 = htmlspecialchars($_POST['user2'],  ENT_QUOTES);
$insert = mysql_query("insert into memberlinks values ('$user', '$user2')") or die("Could not insert data because ".mysql_error());

// print a success message
echo "Your link has been added!<br>"; 
echo "Now you can <a href=change_password.php>add another link</a>"; 

?>

Oppps, noticed that the input boxes were hidden.....

so see update..

also change hidden to text while testing..

 

<?php

$mysite_username = $_COOKIE["mysite_username"];

$conn = mysql_connect($server, $db_user, $db_pass)
or die ("could not connect to mysql");  #Connect to mysql
$rs = mysql_select_db( $database, $conn )
or die ("Could not select database"); #select database 

$sql = "Select link FROM links";  //pull the users from the table

$result= mysql_query($sql)
or die(" Could not add style facts");

echo "<table align=center border=1>";        // display the users in table
$c = 0;
while($row = mysql_fetch_array($result)) { 
//update line below
$user2 = htmlspecialchars($row['link'],  ENT_QUOTES);
  if($c%5 == 0) echo "<tr height=\"200px\">"; // If the counter has ticked 6 times, start a new row.
echo "<td><FORM action='addlinks.php' method='post'><p><input type=HIDDEN name='user' value='$mysite_username'></p><p align=center><input type=hidden name='user2' value='$user2'></p><p align=center>rating script here</p><p align=center><input type=submit></p></form>";

  if($c%5 == 4) echo "</tr>"; // If we're drawing the 6th pic, end this row.
  $c++;
}
if($c%5 != 4) echo "</tr>"; // If there isn't a number of pics divisible by 6, end the row
echo "</table>"; // end the table


?>

 

3am here in the UK, i got to be up in 4hours... night all.

oops that should have said "now display"

 

thanks for all this!

 

so it saves it into the memberlinks table, and changes " to &quot and the like

 

so how do i pull them out again, and back to as it was before...?

hello again!

 

it works in the way that a user can add a link, and when they go back to their page it will be on there.

 

however i have another problem around the same code

 

using the code you gave me it doesn't display the link as an image. just as text so i'm trying to do something like this.

 

can you see where i'm going wrong?  the problem is it's displaying the onmouse...etc etc section

 

<?php
echo "<table align=center border=1>";        // display the users in table
$c = 0;
while($row = mysql_fetch_array($result)) { 
   $user2 = htmlspecialchars($row['link'],  ENT_QUOTES);
   $user3 = $row['link'];

if($c%5 == 0) echo "<tr height=\"200px\">"; // If the counter has ticked 6 times, start a new row.


echo "<td><FORM action='addlinks.php' method='post'>
<p><input type=HIDDEN name='user' value='$mysite_username'></p>
<p align=center><input type=HIDDEN name='user2' value='$user2'></p>
<p align=center>'$user3'</p>
<p align=center>rating script here</p>
<p align=center><input type=submit></p></form>";

  if($c%5 == 4) echo "</tr>"; // If we're drawing the 6th pic, end this row.
  $c++;
}
if($c%5 != 4) echo "</tr>"; // If there isn't a number of pics divisible by 6, end the row
echo "</table>"; // end the table


?>

ok,

 

and so i turn for help again... :)

 

I'm trying to check if the link has already been added for the user using:

 

<?php
//check to see if link has already been added to username

$match = "SELECT link FROM memberlinks WHERE username = '".$_POST['user']."' 
and link = '".$_POST['user2']."';"; 

$qry = mysql_query($match) 
or die ("Could not match data because ".mysql_error()); 
$num_rows = mysql_num_rows($qry); 

if ($num_rows <= 0) { 
echo "You've already added that link.<br>"; 
echo "<a href=change_password.php>choose another</a>"; 
exit; 
}
?>

 

however, user2 is only bringing back half the code again!

 

although we encoded it before the post...?

 

what's going on ?!?

 

Thanks in advance

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.