Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. Sorry, I assumed you knew what you were doing with what I'd posted... [code]<?php $sql = "SELECT SUM(ability) AS total FROM player WHERE team = 'A'"; $result = mysql_query($sql); $row = mysql_fetch_array($result, MYSQL_ASSOC); echo $row['total']; ?> [/code] Regards Huggie
  2. Try something really simple like this, and it will help you to understand the values assigned to each element of the array when it's uploaded. [code]<?php echo <<<HTML   <form name="upload" method="POST" action="{$_SERVER['PHP_SELF']}" enctype="multipart/form-data">   <input type="file" name="image"><br>   <input type="submit" name="submit" value="Upload"><br><br>   </form> HTML; if (isset($_FILES)){   echo "<pre>\n";   print_r($_FILES);   echo "</pre>\n"; } ?>[/code] Huggie
  3. OK, I'll cover that in a minute, in the mean time, try changing this: [code=php:0]if ($_FILES['filename']['type'] != "image/jpeg" || $_FILES['filename']['type'] != "image/pjpeg" || $_FILES['filename']['type'] != "image/gif")[/code] To this: [code=php:0]if ($_FILES['filename']['type'][0] != "image/jpeg" || $_FILES['filename']['type'][0] != "image/pjpeg" || $_FILES['filename']['type'][0] != "image/gif")[/code] and attempt to upload one file and see what happens. Huggie
  4. I think you should be doing something like this (notice I'm using an array key here) I'm sure this is where things are going wrong for you, as each component within the $_FILES array is an array in itself, so [code=php:0]$_FILES['imagefile']['type'][/code] is an array too: [code] <?php foreach ($_FILES['imagefile']['error'] as $k => $error){   if ($_FILES['imagefile']['error'][$k] == 0){       if ($_FILES['imagefile']['type'][$k] == "image/jpeg" || $_FILES['imagefile']['type'][$k] == "image/gif" || $_FILES['imagefile']['type'][$k] == "image/pjpeg"){         // Do your processing here       }   } } ?> [/code] Huggie
  5. Are you only uploading one file at a time? Huggie
  6. And the files you're trying to upload are definitely of one of those types are they? Huggie
  7. Make the first line of your if look like this: [code=php:0]if ($_FILES['filename']['type'] != "image/jpeg" || $_FILES['filename']['type'] != "image/pjpeg" || $_FILES['filename']['type'] != "image/gif")[/code] Not this: [code=php:0]if ($_FILES['filename']['type'] != "image/jpg" || "image/gif" || "image/pjpeg")[/code] That should fix it. Huggie
  8. Checking of what?  the file type? Regards Huggie
  9. Slight variation on what Orio's got... Based on what you've posted, I'd go with this... [code]<?php $pattern = "/<span class=\"brodtext\">(.*?)<div class=\"byline\">/s"; preg_match_all($pattern, $text, $matches); print_r($matches); ?>[/code] The /s modifier allows you to include whitespace and newlines as characters matched by the '.' (period). Regards Huggie
  10. Also, you should add a third file type... "[color=brown]image/pjpeg[/color]". Regards Huggie
  11. Use the image size functions to get the dimensions of each image, then create a canvas that size and merge them in. Regards Huggie
  12. Sorry, my fault. The code I posted should have looked like this... [code]<?php preg_match('/\.\w{3,4}$/', $filename, $matches); $new_filename = $username."1".$matches[0]; ?>[/code] This will work with .jpg, .jpeg, .gif Regards Huggie
  13. OK, with the changes I made, does it work if you try to upload a .gif or a .jpg? Regards Huggie
  14. OK, the chances are you need to know the full path, that's probably the only issue.  The likelihood of your [color=green]test[/color] directory being in the root are extremely minimal! Put this file in the [color=green]test[/color] directory, call it varinfo.php and run it... [code]<?php phpinfo(32); ?>[/code] Look for the value called [b]_SERVER["SCRIPT_FILENAME"][/b] this will give you the full path to the varinfo.php It should look something like this: [color=brown]/home/domains/yourdomain/test/varinfo.php[/color] Chop off the file name and then place the path to the file into this line in your code, so change this... [code=php:0]if ($handle = opendir("test/")[/code] to this... [code=php:0]if ($handle = opendir("/home/domains/yourdomain/test/")[/code] Regards Huggie
  15. Why not just use a regular expression... Give this a try: [code]<?php $filetype = $_FILES['filename']['type']; $username = $_SESSION['username']; $filename = $_FILES['filename']['name']; preg_match("/\.w{3}$/", $filename, $matches); // I added this $new_filename = $username."1".$matches[1]; // and the last part of this $filepath = "pictures/".$new_filename; ?>[/code] This line [code=php:0]preg_match("/\.w{3}$/", $filename, $matches);[/code] just says capture anything that has a period, followed by three letters, followed by an end of line. Regards Huggie
  16. Your welcome, look forward to seeing the progress. Regards Huggie
  17. Yes, that can be done too.  With the code that you've been given in this thread, you should now be able to achieve exactly what you need. Regards Huggie
  18. Use SUM() for that... [code=php:0]$sql = "SELECT SUM(ability) FROM player WHERE team = 'A'";[/code] This will select the total ability for the whole of Team A Regards Huggie
  19. No problem, and you're right, it was an easy one :) Regards Huggie
  20. Not quite, try this... [code]<?php include("config/database.php"); $password = md5($password); $con = mysql_connect("$mysqlhost","$mysqlusr","$mysqlpass") or die('Could not connect: ' . mysql_error()); mysql_select_db($db_name, $con); $results = mysql_query("SELECT * FROM v2_users WHERE name = '$username'"); if (mysql_num_rows($results) > 0) {   echo "name already exists"; } else {   mysql_query("INSERT INTO v2_users (name, pass, jdate, banned) VALUES ('$username', '$password', '$date', '0')");   echo "Registration completed. You can now log in..."; } mysql_close($con); ?>[/code] Regards Huggie
  21. It shouldn't give you any issues.  As for question 2, yes I misunderstood. You could use an include I suppose but that might not work exactly as intended.  It depends on what else is on the page.  This is likely to need more customizing. Regards Huggie
  22. I think you're probably better using [url=http://uk.php.net/manual/en/function.imagecopyresampled.php]imagecopyresampled()[/url] as opposed to [url=http://uk.php.net/manual/en/function.imagecopyresized.php]imagecopyresized()[/url]. Regards Huggie
  23. I'm afraid I don't know how to do it with MSSQL, only MySQL. I've had a scout around, and I think you need to use the [color=green]convert()[/color] function Regards Huggie
  24. In answer to question 1, yes extremely... [code]<?php if ( isset($_GET['nieuws'])) {include('nieuws.php'); } else if ( isset($_GET['directhosting'])) {include('overons.php'); } else if ( isset($_GET['netwerk'])) {include('netwerk.php'); } else if ( isset($_GET['overzicht'])) {include('overzicht.php'); } else if ( isset($_GET['koper'])) {include('koper.php'); } else {include('overons.php');} ?>[/code] As for question 2, I'm not sure how I frames work, but if they're the same as normal frames then you just need to specify the target... [quote]<a href="news/news.php?action=fullnews&amp;showcomments=1&amp;id=$id" [b]target="frame_name"[/b]>$subject[/url] <span class="pa">Geplaatst op $time</span>[/quote] Regards Huggie
  25. How about showing us the code that creates the thumbnails? 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.