Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. Tested the code out, didnt get a 500 internal server error Just moved 3 lines out of the loop, worked fine <?php $file_name = "soubor.txt"; /* this is the file that contains your coordinates */ $lines = file($file_name); /* read the file into an array */ $ne = count($lines); /* count the number of coordinate pairs */ $i = 0; /* set your initial counter */ $image = imagecreatefromjpeg('sal.jpg'); $w = imagesx($image); $h = imagesy($image); $watermark = imagecreatefromgif('checkmark.gif'); $ww = imagesx($watermark); $wh = imagesy($watermark); while($i<$ne) { /* start looping thru the pairs */ $coords = explode(",", $lines[$i]); /* get the coords of the each element */ $x = $coords[0] - 10; /* calculate upper left point */ $y = $coords[1] - 10; imagecopy($image, $watermark, $x, $y, 0, 0, $ww, $wh); $i ++; } header('Content-type: image/jpeg'); imagejpeg($image); exit(); changed the watermark from jpeg to gif so as to have a transparency. [attachment deleted by admin]
  2. Did u try solving this homework by yerself?
  3. Zend Studio - Windows\Linux - Big Projects/Debugging. The Debugger is by far the best UltraEdit - Windows - Its commericial, but a very excellant editor Geany - Linux - Excellant all around editor editor MySQL Workbench - Windows/Linux - The DB Modeling is excellant for designing DB's. MySQLcc - Windows/Linux - A Quick way to edit DB's (Think of myphpadmin but an app) Dia - Windows/Linux - Diagram editor, used on occasion when speed is more of an issue (quick & dirty) Expresso - Windows - Regex Design & Tester GeneratorData - online - When you need some sample data WinMerge - Windows - Comparison & Patch tool Portability DevPHP - Windows - Editor/Debugger (primarily used for debugging) Notepad++ - Windows - Editor. np++ although not geared for debugging, it's still an excellant editor. XDebug Prolly some other tools I can throw in, but thats the builk of the tools. My Comment above, was for the newer coders actually. Some of the tools do have a higher learning curve than others. Some tools are just overwhelming of what they can do. But as with any tool, experience comes with practice and usage.
  4. On page album/category1-s// the link on that page instead read album/category1-s/category1-ss/ and on the page album/category1-w/ the link instead read album/category1-w/category1-ws/. the substr solutions don't account for anything other than ending in w or s, the str_replace method would work, but only if yer certain that the match string is unique.
  5. But a tool is only as good as the operator. if you don't have any exposure to a tool, (Flowcharting, OOP, PHP, Hand Drill, Car) that tool to you is useless. So even if we provide you with a list of the tools we find helpful, the only way to use those tools effectively is by using them and learning them. A Flowchart can about represent anything, its an overview. A Visualization tool. U can make a flowchart on just about anything: database design, program flow, painting a wall, changing a tire on a car.
  6. About only tool you don't mentiion is a decent text editor
  7. The thing that stops you from having a pure mysql solution, is in this query "SELECT rank,wins,loss FROM ladder_$team[ladderid] WHERE teamid='$teamid'" instead of normalizing your data, you opted to create new tables.
  8. I have to agree with anti-moronic. When it comes to implementing an idea into code: 1) Data design/storage 2) codeflow design 3) implementation if you don't have #1 done, you will find that #2/#3 become very difficult. if u need tools to help you with the design, use a diagram editor to visualize how your db/app design should be like. Dia Diagram
  9. Bahh, OOP programming is just a strict methodology of programming. U can use functions without classes, as C became before C++ not after Procedural coding is just as viable methodology of progamming as OOP is. So its not a case of don't use functions without OOP. its a case of Know when to use a function. the connect is a usually a 1 time call, so there is no reason to put this into a function but say u are coding along, and u notice that u continually repeat code. this is where u should use a function.
  10. where do u do a mysql_connect?
  11. If id is a PRIMARY KEY and AUTO INCREMENTED You don't need to put this in your insert query. MySQL can handle this field, this is probably why your getting a white page. $query="INSERT INTO guestbook (name, email, message, date, time) VALUES (".mysql_real_escape_string($_POST['name'])."','".mysql_real_escape_string($_POST['email'])."','".mysql_real_escape_string($_POST['message'])."','".mysql_real_escape_string($_POST['Y-m-d'])."','".mysql_real_escape_string($_POST['H:i:s'])."')"; echo $query; // just for testing purposes... mysql_query($query) or die(mysql_error()); and as MMDE shows, always sanitize user input before inserting into your db.
  12. break the routine apart, it can be modified for those needs. the hard part the regex pattern is already working. if u know that preg_match returns 0 or 1 (0 no match, 1 match) than its not hard to figure out the rest.
  13. $line= trim(implode(' ',array($firstName,$lastName))); if(!empty($line) $line.='<br />"; $companyName=trim($companyName); if(!empty($companyName) $line.=$companyName .'<br />"; echo $line;
  14. yer code has no <br /> or newlines. so how are we supposed to help, if your code snippet has nothing to do with the actual problem? as is your code will display all results on one line
  15. not shure wut u mean. but here is a function, checks for female/male <?php $val="male"; $gender=preg_match('/\b(?:fe)?male/',$val,$match)?(substr($match[0],0,1)=='m'?1:2):FALSE; echo $gender .PHP_EOL; echo ($gender==1?'Male'$gender==2?'Female':'Other')) . PHP_EOL; ?>
  16. any reason u need connect() function? if u remove the function (and of course the global. than just by including the file will connect to the database if your worried about hammering the page, than you can always use defines and an if statement <?php define('InScript',TRUE); include('connect.php'); . . . ?> <?php if(defined('InScript')) $mysql = new MySQLi('localhost','cybershot','pascal35','billPay') or die('couldn not connect'. mysql_error()); ?>[code]
  17. The Where Clause comes before the GROUP and ORDER BY clause SELECT item_id, SUM(amount_remaining) AS 'total' FROM rpg_reciept WHERE userid = '".$userid."' AND amount_remaining <> 'none' GROUP BY item_id ORDER BY item_id
  18. a break statement is to get out of a loop early. what you want is EOL terminators and that depends on your OS/Browser echo "This will work in a browser <br />"; echo "This will work from cli \n"; // \n linux EOL, \r\n Windows EOL, \r Mac EOL echo "This will also work in cli". PHP_EOL; echo "This will work in browser and cli <br />". PHP_EOL; also note that php also has the function nl2br, which converts the EOL \n to a <br /> tag Echo nl2br("This String\nWill be split\nInto 3 lines");
  19. Plenty of ways of doing this I'll give u 2 1) <? header('Content-Type: text/plain'); readfile('file.name'); note: that the use of header and content type, means this file is of that type, so u cant mix this with html. 1) <? $contents=htmlspecialchars(file_get_contents('file.name')); Echo $contents; using htmlspecialchars, to convert html/xml/php/etc file to html encoded file, where html special characters are converted to their meta equivalents, < becomes <
  20. SELECT item_id,SUM(price) AS total FROM reciepts GROUP BY item_id ORDER BY item_Id
  21. Yes, thats pretty much it. as u can see, adding a category and games is made much simpler without the need of creating a new table for each category. but thats a pretty simple design, db's can be very complex if they need to be. but this is a good start to using db and referential links.
  22. REQUEST can be either POST/GET, so a person may overwrite the outcome of one with the other. creating a security hole that wasnt intended.
  23. A Simple DB Designer works wonders. Here we just see 2 tables, categories and games. we define the categories, than in our second table the games, we make a field for the referencial link to the categories table. You wont get categories name automatically from the games table, u do this with JOINs in your sql staement however working with category_id is a lot simpler than working with the categorie's name. mysql will perform faster example SELECT Games.*,Categories.name FROM Games, Categories ON Categories.id = Games.category_id ORDER BY Games.category_id ASC would organize your games by category and retrieve the category name as well Good luck on the project
  24. LOL, I say the same thing, I got a lot of the basics down. prolly only know 20% of what mysql offers.
×
×
  • 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.