-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
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
-
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
-
[SOLVED] $_POST loops with iterated variables and MySQL functions
mikesta707 replied to ba2008's topic in PHP Coding Help
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. -
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
-
php coding software witch one?
mikesta707 replied to supergrame's topic in Editor Help (PhpStorm, VS Code, etc)
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 -
that means your query is failing. put or die(mysql_error()) after your query. also your indentation is atrocious. code is everywhere
-
Multiple PHP Multidimensional Array into mysql
mikesta707 replied to gary_rip's topic in PHP Coding Help
just surround your array entries with {} inside the query. IE {$array[0][$i]} -
How to strip HTML tags, scripts, and styles from a web page
mikesta707 replied to senyo's topic in PHP Coding Help
.. 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 -
How to strip HTML tags, scripts, and styles from a web page
mikesta707 replied to senyo's topic in PHP Coding Help
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... -
How to strip HTML tags, scripts, and styles from a web page
mikesta707 replied to senyo's topic in PHP Coding Help
... 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 -
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
-
$query = "SELECT * FROM `services` order by service "; $results = mysql_query ($query2) or die (mysql_error()); notice something wrong with this?
-
Ok, let me just put on my robe and wizards hat on, so I can divine what your problem is
-
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
-
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
-
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();
-
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) . ")";
-
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"); }
-
refreshing the page sends the post data again, so using unset($_POST) won't work
-
why dont you just convert the short tags to long tags
-
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
-
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
-
don't use notepad. use a code editor, like notepad++ with syntax highlighting. the errors will become obvious then
-
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.