jjk2 Posted July 10, 2008 Share Posted July 10, 2008 im trying to replace video_name with a new name that has random characters added on to it. <?php $conn = mysql_connect('localhost', 'user', 'password') or die ("failed to connect"); $db = mysql_select_db("somedatabase", $conn) or die ("failed to find db"); $result = mysql_query("SELECT * FROM videos WHERE ID > 1186") or die("failed query"); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $tmp_sid = md5(uniqid(mt_rand(), true)); $newname = $tmp_sid . '__' . $row['ID'] . '.wmv; $sql = "UPDATE videos SET original_video = $newname WHERE VIDEOID = $row['VIDEOID']"; $query = mysql_query($sql) or die("epic fail"); mysql_query($query) or die("cannot send query"); } mysql_close($conn); ?> Link to comment https://forums.phpfreaks.com/topic/114012-solved-whats-wrong-with-this-mysql/ Share on other sites More sharing options...
trq Posted July 10, 2008 Share Posted July 10, 2008 Your missing a few quotes. while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $tmp_sid = md5(uniqid(mt_rand(), true)); $newname = $tmp_sid . '__' . $row['ID'] . '.wmv'; $sql = "UPDATE videos SET original_video = $newname WHERE VIDEOID = {$row['VIDEOID']}"; $query = mysql_query($sql) or die("epic fail"); mysql_query($query) or die("cannot send query"); } Link to comment https://forums.phpfreaks.com/topic/114012-solved-whats-wrong-with-this-mysql/#findComment-585981 Share on other sites More sharing options...
jjk2 Posted July 10, 2008 Author Share Posted July 10, 2008 Invalid query: Unknown table '912764293f0a8f3643c056c4df5951bd__100.wmv' in field list Link to comment https://forums.phpfreaks.com/topic/114012-solved-whats-wrong-with-this-mysql/#findComment-585989 Share on other sites More sharing options...
trq Posted July 10, 2008 Share Posted July 10, 2008 $sql = "UPDATE videos SET original_video = '$newname' WHERE VIDEOID = '{$row['VIDEOID']}'"; Link to comment https://forums.phpfreaks.com/topic/114012-solved-whats-wrong-with-this-mysql/#findComment-585994 Share on other sites More sharing options...
jjk2 Posted July 10, 2008 Author Share Posted July 10, 2008 mysql_fetch_array(): supplied argument is not a valid MySQL result Link to comment https://forums.phpfreaks.com/topic/114012-solved-whats-wrong-with-this-mysql/#findComment-586101 Share on other sites More sharing options...
trq Posted July 10, 2008 Share Posted July 10, 2008 Post your code. Link to comment https://forums.phpfreaks.com/topic/114012-solved-whats-wrong-with-this-mysql/#findComment-586103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.