Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. [quote author=Orio link=topic=119118.msg487377#msg487377 date=1166457135] [code]preg_replace("/;[-]+.*?;[-]+/is", "", $text);[/code] [/quote] There's no need for the [color=red]i[/color] modifier.  There's no text in the RegEx, so case sensitivity doesn't come into the equation really. [code]preg_replace("/;[-]+.*?;[-]+/s", "", $text);[/code] Regards Huggie
  2. Is it a varying length or is it always the top 5 lines? Regards Huggie
  3. Yes, flat file DB is definitely what you're after here. Regards Huggie
  4. [quote author=HHawk link=topic=119093.msg487319#msg487319 date=1166452911] Bah... Tried several things. It won't work.  Maybe I should try a crappy perl whois script. [/quote] It's not the script, it's the layout!  It doesn't matter which script you use, they'll all produce the same results. I'll take a look at this when I get home this evening and see how to work around it. Regards Huggie
  5. No problem, I also forgot to mention that it assumes that you only have the 'number' files in the directory.  Other files will cause problems. Regards Huggie
  6. If you don't fully understand file permissions it's not advisable to just change them to 777. Maybe something like 766 would be more appropriate.  This of course is assuming you're on a *nix server as opposed to a Windows server. Regards Huggie
  7. OK, $subtotals is just an array of each of the numbers from each of the files. I place the number from each of the files into that array and then foreach one, add it to $total. Regards Huggie
  8. Perhaps you could tell us what the problem is? Regards Huggie
  9. You can assign them to a different array if you want... [code=php:0]$myAssocGetArray = $_GET;[/code] Regards Huggie
  10. $_GET and $_POST are associative arrays.  You can use them as they are. Regards Huggie
  11. Try something like this should work in it's simplest form, although it's not tested.  It assumes that the only thing in the file is the number that you mentioned.  If it's not then you'll want to perform a regular expression on the information returned. [code]<?php // Directory path $dir = "/path/to/all_of_your/textfiles/"; // Open the directory $dh = opendir($dir); while (($file = readdir($dh) !== false){   $fullfile = $dir . $file;   $subtotals[] = file_get_contents($fullfile); } // Add them all together $total = 0; foreach ($subtotals as $st){   $total = $total + $st; } // Echo the total echo "$total\n"; ?>[/code] Regards Huggie
  12. OK, Having looked at the code, it's exactly as expected.  However, you haven't posted the code for the whole page here.  We'd need to see all the code to be able to help. Huggie
  13. If you post the code then we can take a look at it for you. Regards Huggie
  14. Try something like this: [code]<?php // Query the database for the values $sql = "SELECT value1, value2 FROM table1"; // unless you only have one row you'll want a WHERE clause here $result = mysql_query($sql); $row = mysql_fetch_array($result); // Check the values and assign accordingly if ($row['value1'] > $row['value2']){   $value3 = "Yes"; } else {   $value3 = "No"; } // Insert new data into the database $sql = "INSERT INTO `table1` (value3) VALUES ('$value3')";  // Again, if using a WHERE clause, you'll want it here too. $mysql_query($sql); ?>[/code] Regards Huggie
  15. [quote author=ProjectFear link=topic=119074.msg487214#msg487214 date=1166437979] in both those files fetch_row is only called once, at line 14 on kelly.php and i cant find anywhere where you are defining the function... hmmm... [/quote] There's no need to define the function.  It's a function that's included with the [url=http://uk.php.net/manual/en/ref.mysqli.php]MySQLi[/url] extension. Regards Huggie
  16. It's the order that you have things in the PHP file that's causing this. You're obviously outputting some HTML before searching the whois database, then searching the database and returning the data, then finally outputting the rest of the HTML.  You should probably process the form at the top of the page, get the results, and then output all the HTML with the info in. Or alternatively, maybe try using the output buffer. Regards Huggie
  17. I'm not sure I understand exactly what you mean, the following query will give what you've asked for, but whether it's actually what you want is another thing all together: [code=php:0]SELECT DISTINCT field_2 FROM table_name ORDER BY field_2[/code] Regards Huggie
  18. Morning all, I want to be able to open a .zip file for reading on a Linux box.  My PHP installation isn't compiled with any kind of zip support but it is compiled with the zlib library.  Is it possible to open plain .zip files with this library? I'm sure I saw a class that did this, so I'm assuming it is possible, but I don't want to use anything third party just yet. Regards Huggie
  19. Try this... Can you provide the table names and column names in your database? Regards Huggie
  20. Good point Obs, didn't think of that. This will need a little more thought I think. Huggie
  21. No problem, I was looking at some similar code that I've got and then I realised the difference, you were saying.... if file isn't equal to something or file isn't equal to something else, when I looked at my code it was saying if file IS equal to something or file IS equal to something else.  So you were testing for negative and me for positive, hence the change from OR to AND. Regards Huggie
  22. ted_chou12, Please don't 'hijack' threads.  You made a post relating to this yesterday which I replied to. Did you even try what I suggested yesterday in your other post, you haven't updated it, so are we to assume you haven't?  If so, why are you still seeking solutions when you may already have what you need?  If you have and it didn't work, then please post back in the original thread ([url=http://www.phpfreaks.com/forums/index.php/topic,118583.0.html]problem with listing root directories (UN~SOLVED)[/url]) Huggie
  23. OK, I've read the code and I've been a complete muppet. Try this: [code]<?php session_start(); include("Vars.inc"); if ( $_SESSION['login'] != "true" ) { header("location: hacker.php"); } else { if ($_FILES['filename']['type'] != "image/jpeg" && $_FILES['filename']['type'] != "image/pjpeg" && $_FILES['filename']['type'] != "image/gif")  { echo "Sorry you must upload only files of the type .jpg .jpeg or .gif, Click <a href='picturemanager.php'>Here</a> to try again"; } else { $filetype = $_FILES['filename']['type']; $username = $_SESSION['username']; $filename = $_FILES['filename']['name']; preg_match('/\.\w{3,4}$/', $filename, $matches); $new_filename = $username."1".$matches[0]; $myFile = $new_filename; unlink("pictures/".$myFile); $filepath = "pictures/".$new_filename; echo "<h1 align = 'center'>Your File has been uploaded. Click <a href='picturemanager.php'>Here</a>to Return</h1>";       $source = "pictures";       move_uploaded_file($_FILES['filename']['tmp_name'],               "../xxx/xxx/$source/".$new_filename); // this line is for local host   /*"../xxx/$source/".$_FILES['filename']['name']);*/ //this line is for remote server     $connection=mysql_connect($host, $user, $passwd) or die ("Could not connect !"); $db = mysql_select_db($database, $connection) or die ("Could not connect to Database"); $username = $_SESSION['username']; $query = "UPDATE members SET picture = '$filepath' WHERE user_name='$username'"; $result = mysql_query($query) or die ("could not add picture."); } } ?>[/code] The || (or) was producing a true result everytime.  We needed && (and) to produce a negative result and output the correct details. My work here is done, incidently, you could cut your code down by removing duplicate values, like this: [code]<?php session_start(); include("Vars.inc"); if ( $_SESSION['login'] != "true" ){   header("location: hacker.php"); } else {   if ($_FILES['filename']['type'] != "image/jpeg" && $_FILES['filename']['type'] != "image/pjpeg" && $_FILES['filename']['type'] != "image/gif"){       echo "Sorry you must upload only files of the type .jpg .jpeg or .gif, Click <a href='picturemanager.php'>Here</a> to try again";   }   else{       preg_match('/\.\w{3,4}$/', $_FILES['filename']['name'], $matches);       $new_filename = $_SESSION['username']."1".$matches[0];       unlink("pictures/".$new_filename);       $filepath = "pictures/".$new_filename;       echo "<h1 align = 'center'>Your File has been uploaded. Click <a href='picturemanager.php'>Here</a>to Return</h1>";       $source = "pictures";       move_uploaded_file($_FILES['filename']['tmp_name'],         "../xxx/xxx/$source/".$new_filename); // this line is for local host         /*"../xxx/$source/".$_FILES['filename']['name']);*/ //this line is for remote server       $connection=mysql_connect($host, $user, $passwd) or die ("Could not connect !");       $db = mysql_select_db($database, $connection) or die ("Could not connect to Database");       $query = "UPDATE members SET picture = '$filepath' WHERE user_name='{$_SESSION['username']}'";       $result = mysql_query($query) or die ("could not add picture.");   } } ?>[/code] Regards Huggie
  24. Don't forget, that [code=php:0]$_SERVER['PHP_SELF'][/code] will only give you the path in reference to the domain, not the server. If you want the full path, you'll need to use something like [code=php:0]dirname($_SERVER['PATH_TRANSLATED'])[/code] Regards Huggie
  25. OK, got to do some work now. I'll review your whole code this evening and correct it for you. Regards Huggie
×
×
  • 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.