xshanelarsonx Posted February 13, 2007 Share Posted February 13, 2007 This keep's giving me this error. "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's','aa's.mp3', '0')' at line 1" $songname = aa's mysql_connect("localhost","root","hs") or die ("Unable to connect to MySQL server."); mysql_select_db("Music") or die ("Unable to select requested database."); $music = array(".mp3"); $fname = $_FILES['file']['name']; $ext = strrchr($fname,'.'); if (!in_array(strtolower($ext),$music)) { echo "~~Wrong file extension -- Music*.mp3* only~~<br /><a href='Music.php'>Back</a>"; }else{ $fname = $songname.".mp3"; $fname = str_replace(' ', '', $fname); $fname = stripslashes($fname); $songname = stripslashes($songname); move_uploaded_file($_FILES["file"]["tmp_name"],"Files/Music/" ."$fname" ); $MuscUpload = "INSERT INTO songs(SongName , File, Seconds) VALUES('$songname','$fname', '0')"; mysql_query($MuscUpload) or die("MySQL ERROR: ".mysql_error()); Quote Link to comment Share on other sites More sharing options...
13th_Star Posted February 13, 2007 Share Posted February 13, 2007 change this $fname = str_replace(' ', '', $fname); back to $fname = str_replace("'", "", $fname); Quote Link to comment Share on other sites More sharing options...
xshanelarsonx Posted February 13, 2007 Author Share Posted February 13, 2007 That didn't fix it. Thanks for the try. Quote Link to comment Share on other sites More sharing options...
13th_Star Posted February 13, 2007 Share Posted February 13, 2007 ok so you've got $songname = aa's and your error is: 'aa's' it just looks like it does not like the extra ' in the middle. which you should just take out with the $songname = str_replace("'","",$songname); like you did with the filename Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 13, 2007 Share Posted February 13, 2007 Test this and ur see ur self that the str_replace function does work as you was told ok <?php $fname="red'arrow's"; $fname = str_replace("'", "", $fname); echo $fname; ?> Quote Link to comment Share on other sites More sharing options...
xshanelarsonx Posted February 13, 2007 Author Share Posted February 13, 2007 Thanks for all the help. I figured out that it must be a combo to work. $fname = stripslashes($fname); $fname = str_replace("'", "", $fname); Not just. $fname = str_replace("'", "", $fname); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.