Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. they are newline characters. In plain text (which text areas are) line breaks are caused by new lines. In html they are caused by the line break tage (<br />) Marcus is correct, you should look into the nl2br() function edit: oh nvm then too late
  2. For the stdObject, I'm not sure. For your own defined class, you can use the magic __call method, and create a static registerMethod method to dynamically add functions. consider the following class Dynamic { //This is an array with all the classes methods. we can define the methods outside the class static protected $methods = array(); //this will register any method we want to the class, by adding it to the array public static function registerMethod($method) { self::$methods[] = $method; } //this is where the "magic" happens. This function gets called when you call the method //it will see if the function is in the methods array, and then call it private function __call($method, $args) { if (in_array($method, self::$methods)) { return call_user_func_array($method, $args); } } } //example //define a simple function function test() { print "Hello World"; } //call our static method to add the test function to the class Dynamic::registerMethod('test'); //instantiate the class $d = new Dynamic(); //now call the method $d->test(); if you wish to read more about it, Here is where I got the idea from, and you can also view the rest of PHPs magic methods at the manual class Foo {} $foo = new Foo(); $foo->bar = function() { echo 'test'; }; I wouldn't recommend that kind of code though. I actually tried something similar to this at first, and it didn't work. I copy pasted this also, and it doesn't work. error: Parse error: syntax error, unexpected T_FUNCTION in C:\Server\htdocs\text.php on line 8
  3. You could always just create a link, with a get variable attached to it, IE <a href="delete.php?id=12" >delete</a> instead of 12 you would put whatever the id for that specific loan is. Then on the delete page you could just use the GET variable to decide which loan to delete. Obviously you would want to check that the specific loan belonged to that specific user (other wise people could just delete another persons loans) and the normal sanitation stuff.
  4. you can hash a string with one of PHP's hashing functions. for example $string = "I am a string"; print md5($string); output: 1710528bf976601a5d203cbc289e1a76 you can use any string really
  5. NetBeans has a preview option I think. Eclipse might also. I use Dreamweaver, which I consider one of the (if not the) best web developer IDE that I've used. That isn't technically free, but you can get it for free pretty easily
  6. that means your query is failing. put or die(mysql_error()) after your query. also your indentation is atrocious. code is everywhere
  7. just surround your array entries with {} inside the query. IE {$array[0][$i]}
  8. .. do you know what a function is? if you don't; learn PHP before you try to just copy paste code and put it on your website. debugging your code will be much less of a headache
  9. please put your code in code tags. How are you using the function? can you show an example of where you use it in your code. that function seems perfectly fine...
  10. ... it strips php tags from the strings, which seems pretty obvious given its name. Before you try to use someone else's code, I suggest you learn PHP basics, or at least so you can actually make it work. it seems you don't even know how functions work
  11. BTW I believe join would do exactly what you want. I'm not a SQL guru or anything, but I am pretty sure JOIN can be used instead of doing queries in a while
  12. $query = "SELECT * FROM `services` order by service "; $results = mysql_query ($query2) or die (mysql_error()); notice something wrong with this?
  13. Ok, let me just put on my robe and wizards hat on, so I can divine what your problem is
  14. you are concatenating incorrectly. you should use an editor with syntax highlighting, because the error will become very apparent. $query = "SELECT * FROM `users` WHERE `userid` = " . $USERID AND `pin` = " . $PIN;//bad query $query = "SELECT * FROM `users` WHERE `userid` = " . $USERID . " AND `pin` = " . $PIN; //fixed
  15. put or die(mysql_error()) after the query. it is probably failing. if i were to guess it would be the semi colon at the end of the query
  16. in order to accomplish what you want you need to supply your script with more cowbell. IE $array = array();//array for data $array = getMoreCowbel($array);//array with cowbell you may also need additional pylons. you can use PHP's ToSS object for that $probe = new ToSS($array);//we need a array with cowbell to pass into the object; $probe->buildAdditionPylons(); //to be safe, you may want to get some vespene too $probe->getVespene();
  17. when you have arrays queries you surround them with curly brackets. for example, you would do {$_POST['fName']} but for each time you access an array. also you don't need a semi colon at the end of the sql query also you should concatenate the return value for the date function. I don't believe you can just stick functions in strings like that $sql = "blah blah blah " . date(YYYY-MM-DD HH:mm:SS) . ")";
  18. well without AJAX. you won't be able to do it without the onclick doing a page reload. You could have an ajax request get the next 5 items, and fill out the innerHTML with the info, but it would be easiest to do a simple pagination script. there is a tutorial on this website for one of those
  19. thats because preg_match returns true of false (or rather, values that evaluate to true of false) you probably meant to do $pattern = '/[A-Za-z]+/'; if (isset($_POST['name']) && preg_match($pattern, $_POST['name'])) $name = $_POST['name']; $sql="INSERT INTO mytable (names) VALUES ('$name')"; header("Location: http://localhost/php_sandbox/dbtest/index.php"); }
  20. refreshing the page sends the post data again, so using unset($_POST) won't work
  21. why dont you just convert the short tags to long tags
  22. it might be because of this if ($_SESSION['level'] == '1') { remove the single quotes. right now you are comparing an integer to a string, and that may be causing problems
  23. you could set a session or cookie after they upload, and every time a user tries to upload check if the session/cookie is set
  24. don't use notepad. use a code editor, like notepad++ with syntax highlighting. the errors will become obvious then
  25. dont use a while loop. just do $row = mysql_fetch_assoc() its just 1 entry right? well the while loop will store the right value for the first run, but it will try to run again. when it does that mysql_fetch_assoc() will return false because there are no more rows to return, and then $row will have the value of false.
×
×
  • 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.