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()); Link to comment https://forums.phpfreaks.com/topic/38259-solved-mysql-problem/ 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); Link to comment https://forums.phpfreaks.com/topic/38259-solved-mysql-problem/#findComment-183294 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. Link to comment https://forums.phpfreaks.com/topic/38259-solved-mysql-problem/#findComment-183295 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 Link to comment https://forums.phpfreaks.com/topic/38259-solved-mysql-problem/#findComment-183297 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; ?> Link to comment https://forums.phpfreaks.com/topic/38259-solved-mysql-problem/#findComment-183298 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); Link to comment https://forums.phpfreaks.com/topic/38259-solved-mysql-problem/#findComment-183305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.