Sorry bout the confusion this is what I am asking. I am trying to send videos to an ftp server but I do not want the videos that already exist on the ftp to be re uploaded. Hence i need a way to tell the database to do that. What I have is below, made a change thanks to @neo but it 开发者_如何学Gostill returns and invalid query.
<?php
$dest="/Tools";
$query = "SELECT videoid AS videoId FROM videos
WHERE channel = 62 AND videoid NOT IN (@videoId)";
$results = mysql_query($query);
$server=("ftp.//");
$connect=ftp_connect($server);
$login_result=ftp_login($connect,"","");
if(!(login_result)||!($connect))
{
$error;
}
else
{
echo "success";
}
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
// loop through every videoid returned, ftp each individually
$upload=ftp_put($connect,$dest,$row['videoid'],FTP_BINARY);
if (!upload)
{
echo "failed to upload $results\n";
}
else{
echo "successfully uploaded $videoid";
}
ftp_close($connect);
}
mysql_free_result($result);
?>
SELECT shoes.shoeid AS shoeId FROM shoes WHERE color = RED AND shoes.shoeid NOT IN (@shoeID);
Where @shoeID is a comma separated list of shoe ids that are already been uploaded into the FTP location
Do you mean something like :
SELECT shoes.shoeid AS shoeId, sox.shoeid AS soxId
FROM shoes, sox
WHERE color = RED AND sox.shoeid = shoes.shoeid;
That would return the field with their new alias : shoeId
and soxId
NOTE : That is built on the MySQL logic. It should work on other sql engine, but not tested.
You have to get the list of Shoes which has already been uploaded to server.
Either put a flag in db as said be "Neo" else traverse through all the shoes on FTP server and then get it passed to db. Though the latter is not recommended at all.
精彩评论