Why does the following place a \ into the text. ie: (You\'re)
Code:<?php $con = mysql_connect("localhost","music","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("music", $con); $Title=mysql_real_escape_string($_POST['Title']); $Artist=mysql_real_escape_string($_POST['Artist']); $Download=mysql_real_escape_string($_POST['Download']); $Year=mysql_real_escape_string($_POST['Year']); $sql="INSERT INTO Songs (Title,Artist,Download,Year) VALUES ('$Title','$Artist','$Download','$Year')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Music successfully added to your database...."; echo "<img src=arrow.gif>"; mysql_close($con); ?>
The Page Code
Code:<html> <head> <title>Search Years</title> </head> <body bgcolor="#EDD7F1" text="#733582" link="#733582" vlink="purple" alink="red"topmargin="0" leftmargin="10"> <center> <form action="Years_Search.php" method="post"> Search Years <input type="text" name="searchterm"> <input type="submit" value="Search"> </form></center> </body> </html><?php $searchterm = $_POST['searchterm']; trim ($searchterm); if (!$searchterm){ echo 'Please enter a search term.'; } /*add slashes to search term*/ if (!get_magic_quotes_gpc()) { $searchterm = addslashes($searchterm); } @ $dbconn = new mysqli('localhost', 'music', 'pass', 'user'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "select * from `Songs` where `Year` like '%".$searchterm."%'"; $result = $dbconn->query($query); /*number of rows found*/ $num_results = $result->num_rows; echo '<p>Found: '.$num_results.'</p>'; /*loops through results*/ for ($i=0; $i <$num_results; $i++) { $num_found = $i + 1; $row = $result->fetch_assoc(); echo "<b>{$row['Year']} - {$row['Artist']} - {$row['Title']} - <a href=http://somewhere/music_download.php?f={$row['Download']}>Download</a> - <object type=\"application/x-shockwave-flash\" data=\"http://somewhere/player.swf\" width=\"180\" height=\"20\" id=\"audioplayer1\"><param name=\"movie\" value=\"http://somewhere/player.swf\" /><param name=\"FlashVars\" value=\"playerID=1&bg=0xf8f8f8&leftbg=0x8297cc&lefticon=0xffffff&rightbg=0xe09e7b&rightbghover=0xb35884&righticon=0xffffff&righticonhover=0xffffff&text=0x666666&slider=0x666666&track=0xFFFFFF&border=0x666666&loader=0x9FFFB8&soundFile=http://somewhere/Files/{$row['Download']}\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"true\" /><param name=\"bgcolor\" value=\"#EDD7F1\" /></object></b>"; echo "</br>"; } $result->free(); $dbconn->close(); ?>
Any help would be appreciated........



Reply With Quote



Bookmarks