Jump to content

[SOLVED] whats wrong with this mysql ?


jjk2

Recommended Posts

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

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");

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.