Jump to content

Clinger

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Clinger's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Undefined variable warnings are warnings telling you that your using a variable before it has actually been creating. For example: <?php $x++; ?> The above will throw an error because $x has not been defined yet. The reason it worked fine on your remote host is probably because they had error reporting turned off in the php.ini. You can solve this in two ways: 1) Fix your code. 2) Turn off error reporting in PHP.ini
  2. Not entirely sure what you are trying to say / do. But htmlspecialchars will convert all your html characters such as < to <, etc. That will allow yout to display the code..
  3. Try viewing the source to ensure that it is a questionmark. Sometimes HTML will draw questionmarks.
  4. Replace the $_FILES['imagefile'] with $_FILES[$key]
  5. Try enclosing variables in {} when you use them in the sql string. If that doesn't work, try outputting that string to see what the actual sql result is.
  6. I seperate my upload function and do a lot of the validation inside of it, but you can run a basic script like this. <?php foreach ($_FILES as $key=>$file) { if (!empty($file['name'])) { uploadFiles($key); } } ?>
  7. I would say option 1 is your best option. Instead of using timestamps in MySQL, I sometimes do it myself to as well so you mysql statement will require no math. //Registration: $date=date("YmdHis"); //This will return YYYYMMDDHHIISS $expirationDate=$date+10000000; // 10 Days //Set your expDate mysql field to the $expirationDate value. Now when you check the login, you can do this: $date=date("YmdHis"); $sql="SELECT * FROM `Database` WHERE `expDate` > '{$date}'";
  8. If you wanted to print out absolutely every value: <?php //Put all your database connection stuff here. $sql="SELECT * FROM `TABLENAME` WHERE `COLUMN` = 'CONDITION'"; if ($query=@mysql_query($sql)) { if (mysql_num_rows($query) > 0) { while ($req=mysql_fetch_array($query)) { $string=""; foreach ($req as $key=>$value) { $string.="{$req[$key]} = {$value},"; } //Do whatever you need with your string here. } } } //Close your database connection ?> ?>
  9. You could set up a cron job that clears out files dating older than a certain point.
  10. I've never seen this until just recently. When I read a directory using readdir, in addition to the usual ".." and ".", it is now returning a string that says "No Files Currently". 2 Questions. 1.) Why the **** would PHP return a string like that? If the directory is empty, it shouldn't return anything. 2.) How do I disable that? Example: <?php $handle=opendir("blah/"); while (false !== ($file=readdir($handle)) { if (($file != "..")&&($file != ".")) { echo "blah"; } } ?>
  11. I was actually thinking that the cron could run a script like this. It seems to be capable of scanning the files relatively fast. Basically what it would do is identify each different word and stores it in the database with the file ID and line number. I figure this will create a large database eventually, but if I split it seperate tables alphabetically, I think it might be ok. What do you guys think? Would it destroy the database? [code]$dir="00"; $linex=0; $all_words=array(); $handle=opendir($dir); $id_link=mysql_connect("*****", "******", "******"); mysql_select_db("******"); while (false!==($file=readdir($handle))) { if ($file!="."&&$file!="..") { $sql="SELECT * FROM `files` WHERE `filename` = '{$file}'"; if (mysql_num_rows(mysql_query($sql)) == 0) { echo $file."<hr>"; $conts=file_get_contents("{$dir}/{$file}"); $lines=explode("\n", $conts); foreach ($lines as $line) { $linex++; $line=trim($line); $words=explode(" ", $line); foreach ($words as $word) { $word=preg_replace("@<<[^>]+>>@i", "", $word); $word=preg_replace("@[._(),*$!?'\[\]\"]+@i", "", $word); $word=trim($word); if (!empty($word)) { $word=strtolower($word); if (!isset($all_words[$word])) { $all_words[$word]="{$linex}"; } else { $all_words[$word].=",{$linex}"; } } } } $sql="INSERT INTO `files` (`filename`) VALUES ('{$file}')"; $query=mysql_query($sql); $fileID=mysql_insert_id(); $ix=0; $ux=0; ksort($all_words); foreach ($all_words as $key=>$word) { $sql="SELECT * FROM `words` WHERE `WORD` = '{$key}'"; if (mysql_num_rows(mysql_query($sql)) > 0) { $updates[$ux]="UPDATE DELAYED `words` SET `MATCHES` = CONCAT(`MATCHES`, '{$fileID},{$word};') WHERE `WORD` = '{$key}'"; } else { $inserts[$ix]="('{$key}', '{$fileID},{$word};')"; $ix++; } } if ($ix > 0) { //Run INSERT command. $insert="INSERT INTO `words` (`WORD`, `MATCHES`) VALUES "; $insert_line=implode(",", $inserts); $insert.=$insert_line; if (!mysql_query($insert)) { echo mysql_error(); echo "<hr>{$insert}"; } } break; } } } mysql_close($id_link); [/code]
  12. I have a project to scan Optical Character Recognition files. There will be TXT files containing all the words in the document. I need a way to search through all these files quickly. There are going to be a lot of files, and each file is usually somewhat large. (2-3mb each) I am not looking for "coding help", but a better way of doing this. Right now I can think of two options. 1.) Scan through all files directly. (Which will take a very long time if there ends up being a lot of files.) 2.) Set up a cron job that calls a PHP script that indexes the words in each file and stores them in a database. Then when a user searches, it links the search words to the database and pulls the relevant files. Anyone have any better ideas? The files will be uploaded VIA FTP so I can't just automatically scan them when their uploaded. I also have to make sure that I scan all of the files information. I can't just do a quick catch of the first few lines. The search has to be capable of finding the content in any of the pages.
×
×
  • 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.