-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
Session variable is not running in Mozilla But running in IE
JonnoTheDev replied to gagan22's topic in Applications
Post the code for both parts login1.php & hoa.php -
[SOLVED] How to send my email form to more than one email?
JonnoTheDev replied to artweb's topic in PHP Coding Help
mail("user@example.com, anotheruser@example.com", ........ Always check the php manual for usage of functions http://uk.php.net/manual/en/function.mail.php -
if($_POST['submit']) { $filename = $_POST['filename']; $temp_code = stripslashes($_POST['template']); $fa = fopen( $filename, "w" ) or die("Error opening $filename"); fwrite($fa, $temp_code); fclose( $fa ); } Also look at this line if($_POST = 'submit') { Change to if($_POST['submit']) {
-
Then don't!. What is the problem, you are not making it very clear.
-
Never! Not if you want to rank your website on search engines. You are looking for a mod rewrite that will rewrite: http://www.xyz.com/index.php?page=contact to http://www.xyz.com/contact Check the mod rewrite boards. This is simple.
-
Then simply dont use the function htmlentites() or htmlspecialchars()
-
PHP Search with Mysql, Multiple form variables
JonnoTheDev replied to imperium2335's topic in PHP Coding Help
You need to build up the sql based on the form fields entered. So you start of with the basic sql (also escape any user input prior to running a query): $word = mysql_real_escape_string($_REQUEST['word']); $sql = "SELECT * FROM image_bank WHERE tags LIKE '%".$word%."'"; Then check the additional fields and add to the query if(strlen($_REQUEST['field2'])) { $field2 = mysql_real_escape_string($_REQUEST['field2']); $sql .= " AND tags LIKE '%".$field2%."'"; } Then run the query mysql_query($sql); -
Your probably creating an infinate loop here. Also your methodology is wrong. If you want to return a player number that hasn't already been used then your function should do the following 1. Take in both arrays 2. Remove all players from the players array that are in the used players array 3. Obtain a random player from the players array You will never get a used player as there will be none to select from. Also use array_rand() to return a random array key: // give me 1 player at random $player = array_rand($players_array, 1); return $players_array[$player];
-
NO You are checking the post array here: if(isset($_POST)){ and then checking again in the function: if(isset($_POST)){ The $_POST array is outside the scope of the function so will always return nothing. By using a switch / case you are assuming that the form fields names will always be username, etc. You could end up with a huge set of cases to cater for the forms in your website and you also have no way of checking if your form field names are in the switch / case. You are better validating the fields simply using: // check for an empty field if(!strlen(trim($_POST['name']))) { $error = true; } or write a function i.e. check a username is between 5 and 10 characters function checkUsername($name) { $username = trim($name); if(strlen($username) < 5 || strlen($username) > 10) { return false; } return true; } if(!checkUsername($_POST['username'])) { $errors = true; }
-
Identify that an argument passed in isn't an array
JonnoTheDev replied to Xu Wei Jie's topic in PHP Coding Help
if(!is_array($val)) { print "not array"; } else { print "is array"; } -
The extended / parent class are of the same object. When extending a class you must use the keyword 'extends' class a class b extends a When instantiating b I have all of the properties / methods of class a available to me as b is an extension of a. Read some tutorials on extending classes
-
A class needs to be extended in order for the subclass to access its properties / methods as long as the properties / methods access levels allow it (public, private, protected) class a { public $x; } class b extends a { public function setVal($y) { $this->x = $y; } } $obj = new b(); $obj->setVal(123); print $obj->x;
-
Post on the CSS forums, this topic is not associated with php
-
Am I allowed to encrypt a project that uses open source files?
JonnoTheDev replied to killerb's topic in Miscellaneous
No you can do what you want with it as long as its in the terms of the licence from the supplier. i.e. thay may want you to keep certain text in the footer like 'powered by wordpress' or something. You just can't sell it on. -
If you find a code library that can do what you are after then let us know. Another suggestion is to strip an open source ecommerce store open, it may contain multi currency functionality. Other than that you're on your own.
-
At this part of the file: $settings['siteDir'] = ''; You need to put the path to the website files between the single quotes from the root of the computer. i.e. on windows the root is c:\ linux is / Example: the path to my documents is c:\my-documents Now I dont work on windows so I dont know if you can use c:\ but im pretty sure you can use / for the root so: $settings['siteDir'] = '/webspace/wwwroot/'; I'll let you finish it off
-
There is a php api for ffmpeg rather than using the CLI http://ffmpeg-php.sourceforge.net/ To see errors if you are using ffmpeg as a CLI operation I guess you would have to store the output from the command line
-
Cookie problem and yes i don't have any tags before the setcookie
JonnoTheDev replied to trasseli's topic in PHP Coding Help
It could be another part of your code at fault. i.e. you are setting the cookie value from the $_POST array. This may be empty without you realising it. To test cookies create a test file i.e. test.php Put the following code in the file and upload it to your webserver setcookie("user", "joe bloggs", time()+3600); print $_COOKIE['user']; Open the page in the browser and refresh it. What do you see? -
Its easy to find all countries currency codes and symbols. Took me 2 seconds on Google. Like I said store them in a currency database table. If you have found a PEAR package to get you exchange rates then great. I would store them in the table along with the currency code and symbol. Write a script to get the exchange rate updated i.e. once per day. http://www.xe.com/symbols.php I would prefer to implement my own system but if you want guides then search Google. Heres one I found: http://www.talkphp.com/general/1422-creating-simple-currency-converter-automatic-symbols.html
-
No php function available. You need a database table of all currencies, iso codes, symbols, and current exchange rates you wish to use. Pull this information out to use in your drop lists. Exchange rates change all the time so you will need to write an update script that can get the data from an external source, that is unless you want to manually add the rates in.
-
Are you referring to the file upload part? You mean if a user attempts to upload a file of an unsupported format? ffmpeg doesn't do error handling as it is a command line application. You need to make sure that you do not use it with garbage files. Your file upload should only accept certain file types i.e .mov, .mpeg, etc
-
What a long winded method. Why not use javascripts own confirmation alert and then if a user clicks ok delete the record on the same page i.e. Heres your javascript function function decision(message, url){ if(confirm(message)) location.href = url; } Heres the link to delete a record. When a user clicks ok at the prompt it will run index.php?action=delete&id=117 (117 is the database id) <a href='#' onclick="decision('Are you sure you want to delete?','index.php?action=delete&id=117')">delete</a> On your index.php or whatever the file is put the code to delete a record: if($_GET['action'] == 'delete') { // code to delete - database id in $_GET['id'] }
-
Not familiar with your classes but could esily be done with DOMDocument(); Examples: http://uk3.php.net/manual/en/class.domdocument.php
-
There is nothing really on this site that jumps out and says I would use these guys to do my website. You have little call to action. Browsing through web design agency websites this is the look that I would go after. http://www.netdreams.co.uk/index.html Nice portfollio, blog, list of product offerings, easy navigation
-
failed to open stream: No such file or directory in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\includes\DbConnector.php on line 6 Your include paths are wrong! Add the web directory to that array: i.e $settings['siteDir'] = '/myfile/mywebsite.com/docs/'; Whatever the path is to the document root of the website