php - copy content of text file and inserting into database table where a given column is equal to the title of te text file -
i have folder text files. text files created when user submit form data , named based on user input of particular column, use these file contents update 1 table in database using clause 2 conditions, first email of user correspond email column in table, , second file title correspond title column in table. each row, have the content of file it's title correspond saved in seen column.
i'm using below code it's not working
$size = ""; $dir = "counters/ads"; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if($file == '.' || $file == '..') continue; $myfile = "$dir/$file"; $fh = fopen($myfile, 'r'); $size = filesize($myfile); if ($size > 0) { $content = fread($fh, $size); $name = $file; } $target = $row2['target']; $progress = ($content/$target)*100; // check connection $result3=mysqli_query($db_handle,"update advert set seen='$content', progress='$progress', counter='$name' email='".$email."' && title='".$title."'"); fclose($fh); } closedir($handle); } however when removed title condition, query update table inserting $name counter column, it's not updating $content seen column
please idea on how can go it
the problem code semi-colon before where clause:
counter='$name'; it terminates process. need remove it.
since semi-colon valid character in php, not have thrown error it.
it's what's called "end of statement" character.
reference:
as in c or perl, php requires instructions terminated semicolon @ end of each statement. closing tag of block of php code automatically implies semicolon; not need have semicolon terminating last line of php block. closing tag block include trailing newline if 1 present."
it's best check errors using php's error reporting , mysqli_error() on query, in case.
references:
Comments
Post a Comment