-
Posts
2,527 -
Joined
-
Last visited
Everything posted by DeanWhitehouse
-
Most scripts are custom to the sites and the owners needs.
-
If you show your whole loop... You can do something like <?php $i = 0; while($rows = mysql_fetch_assoc())//fill it in propers { if($i == 3) { echo "<br>"; $i =0; } echo $rows['stuff']; $i++; } ?>
-
Or you could use my solution
-
So you want to get all the records that have the a certain word any where in them like? tester has the word test in it or i am a tester testing this test has the word test in it once? If the latter then you can use the SQL clause LIKE
-
<?php if (date("U") > date("U", mktime(12,0,0,date("F"),date("d"),date("Y"))) { header("Location: /afternoonschedule"); } else { header("Location: /morningschedule"); } ?>
-
Using a TARGET within a URL link without using quotes
DeanWhitehouse replied to jdeclan's topic in PHP Coding Help
Without looking at your code i would just say replace the print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; with echo "There is an error"; If you want another way to do this i have just wrote this code for my snippet site <?php //Filename: contact.php //Description: This is a simple contact form to allow people to contact you. //Un-tested function make_safe($un_safe)/*Nice little function i made to run the code through some safety measures*/ { $safe = trim($un_safe);//Removes any whitespace $safe = htmlentities($safe);/*makes any tags into safe versions (special char versions)*/ return $safe; } function check_len($check,$remove)/*used to check the length of a word (can also remove any spaces in the word)*/ { if($remove == true) { $check = str_replace(" ","",$check); } $check = make_safe($check); $check = strlen($check); return $check; } //To learn how to send a basic email from php refer to my previous mail tutorial //http://djw-webdesign.awardspace.com/code.php?snippet=3 //Or the php manual http://uk3.php.net/manual/en/function.mail.php if(isset($_POST['Send_me'])) { //Save everything posted in a variable and make it safe $name = make_safe($_POST['Name']); $email = make_safe($_POST['Email']); $query = make_safe($_POST['Query']); $message = make_safe($_POST['Message']); //Check the length of all the compulsary inputs if(check_len($name,true) == 0) $error[] = "Please enter your name"; if(check_len($query,true) == 0) $error[] = "Please select what the message is regarding"; if(check_len($message,true) == 0) $error[] = "Please enter a message"; //Check for certains chars in an email address if(check_len($email,true) > 0) { $real = array("@","."); if(strpos($email,$real) == 0) $error[] = "Invalid email address"; } //If there is no variable called $error if(!isset($error)) { //Sent From $sender = "Someone somwhere < someone@somesite.com >"; //About $subject = "Site contact - ".$query; //Sent To yourself $recipient = "me< Me@hotmail.com >"; $message = " <html> <body> You have recieved a message from ".$name." from the site.<br> They contacted you regarding ".$query.".<br> They left this email for you to reply to them on.<br><a href=\"mailto:".$email."\">".$email."</a> </body> </html> ";//you will need to escape any double quotation marks.like shown above. $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:'. $sender . "\r\n"; //for more information on headers refer to the php manual mail function. mail($recipient,$subject,$message,$headers);// PHP manual function reference - http://uk3.php.net/manual/en/function.mail.php } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Mail Form</title> </head> <body> <?php if(isset($error)) { echo "There was an error proccessing the request, please correct the below errors<br>"; foreach($error as $er) { echo " ".$er."<br>"; } echo "<br>"; } ?> A star(*) indicates a compulsary input field. <!-- This is a basic form that we will use for inputting the mail, there are html tutorials to explain how to use forms --> <form action="" method="post"> *Name: <input type="text" name="Name" value="" maxlength="20"><br> Email: <input type="text" name="Email" value="" maxlength="20"><br> *Regarding: <select name="Query"> <option selected="selected" disabled="disabled"></option> <option value="general">General</option> <option value="snippet error">Snippet Error</option> <option value="missing page">Missing Page</option> </select> <br> *Message: <br> <textarea rows="5" cols="30" name="Message"></textarea> <br> <br> <input type="submit" name="Send_me" value="Send Mail"> </form> </body> </html> -
Hmm, i suppose lucky it hasn't happened to me yet and that i don't modify it before i put it in (much)
-
Using a TARGET within a URL link without using quotes
DeanWhitehouse replied to jdeclan's topic in PHP Coding Help
Instead of redirecting them if there is an error. Why not just show an error message on the same page? Also i don't think there is any way in PHP or HTML to redirect to another page (in a new tab/window) without the user clicking a link. You could always try javascript -
@thorpe, that is just a matter of opinion.
-
loading ads from .txt files or mysql ?
DeanWhitehouse replied to TEENFRONT's topic in PHP Coding Help
Opening a file is slower and uses more resources than reading a mysql database. I would say you just need to upgrade your hosting package to a dedicated server if the current one can't cope. Although i am not an expert in Servers or response times. -
To make it safe to print on screen (if he does later , saves him doing so) and to stop it from affecting the query (although i think mysql_real_escape_string(); might stop that.
-
Damn, lol
-
<?php function add_zero($num) { if(strlen($num) != 5) { $i = 0; $diff = 5 - strlen($num); while($i < $diff) { $num = 0 .$num; $i++; } return $num; } else { return $num; } } echo add_zero(1); echo "<br>"; echo add_zero(204); echo "<br>"; echo add_zero(12345); ?>
-
I think you will need to write your own function for this. Gimme me a minute and i will write one.
-
@thorpe, I said first not instead.
-
Use htmlentities(); first
-
What numbers are you using. Show us what the beginning number is and the expected end number. Then we will be able to help better.
-
Using a TARGET within a URL link without using quotes
DeanWhitehouse replied to jdeclan's topic in PHP Coding Help
meta refresh doesn't have a target attribute, therefore you cannot control where it refreshes the page. It would be better for you to rethink your logic. -
HELP!! - PEAR SMTP Mail, on Windows XP - OPEN TO OTHE OPTIONS...
DeanWhitehouse replied to lmaster's topic in PHP Coding Help
http://phpmailer.codeworxtech.com/ http://uk.php.net/manual/en/function.mail.php -
Definitely When i learned how to use databases i knew none of that, i still know only a small amount of it. When you have learned that, you will be able to plan and create databases that make your work a lot easier. Edit: Also eddie i would advise looking at code snippets and working out how they work and in effect learning new functions etc. It just so happens i have a code snippet site http://djw-webdesign.awardspace.com/snippet.php?cat=1 That is the php section. I would also say you should visit sites such as tizag.com and w3schools.com
-
Excel spreadsheet, read and write php
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
Tried it and excelwriter couldn't get either to work properly (needed some other files i couldn't find), and neither allow editing. Only read and write, nevermind will convince them to use mysql. -
Multiple images into ONE large image using PHP?
DeanWhitehouse replied to galvin's topic in PHP Coding Help
There is no pre-built function for it, you need to learn how to use image GD functions. You could always use CSS/HTML to just visibly merge the images on the page. -
Multiple images into ONE large image using PHP?
DeanWhitehouse replied to galvin's topic in PHP Coding Help
Yes, look at image gd functions -
[SOLVED] how do i re-number my rows in my db
DeanWhitehouse replied to Lodius2000's topic in PHP Coding Help
And the problem with that is? It doesn't matter if you have a gap in the numbers as they are just used as unique identifiers. -
ID3 algorithm Decision tree in php
DeanWhitehouse replied to oriental_express's topic in PHP Coding Help
To create php files you would just use fwrite