-
Posts
760 -
Joined
-
Last visited
Posts posted by joel24
-
-
I would also recommend storing them as images and then just pointing to the image location with the database... seems like you've made up your mind, there is a tutorial here
-
you're not setting the variable $s, it is always empty and set to 0
if (empty($s)) { $s=0; } $query .= " limit $s,$limit";
-
you have the next etc url set to use the variable $PHP_SELF though you never set this variable... I would just replace this with the filename, i.e. index.php rather than setting
$PHP_SELF = $_SERVER['PHP_SELF'];
-
whichever page the action points to will be able to detect what request method was used to access the page
i usually check to see if a form element isset before processing
if (isset($_POST['formElementName'])) { //process form }
-
it seems there some null / blank values in your table?
check that $tzone is echoing the correct value and maybe add a where clause to the SQL to test it,
WHERE name != '' AND name IS NOT NULL
-
duplicates (of a particular value) between sub-arrays.
took a quick glance and misread the question, apologies.
-
use unix times (seconds passed since 1st Jan 1970) and then just work with numbers, the strtotime() function is very useful...
i.e.
//current time $time = time(); $min = strtotime("6:00pm"); $max strtotime("6:30pm"); if ($time >= $min && $time <= $max) { echo 'time is between'; } else { echo 'not between'; }
-
try run this so you can see the timezone that's throwing the error and post back
require_once("dbconnection.php"); function coun_list() { $rs=mysql_query("select name from timezones") or die(mysql_error()); while($row=mysql_fetch_row($rs)) { $tzone=$row[0]; if($tzone=='Asia/Calcutta') $tzone='Asia/Kolkata'; try { $tz = new DateTimeZone("$tzone"); $lt=$tz->getLocation(); $lat=$lt['latitude']; $lon=$lt['longitude']; echo "$tzone"; } catch (Exception $e) { echo 'Caught exception on timezone ['.$tzone.']: ', $e->getMessage(), "\n"; } } } coun_list();
-
put this line up the top, quick look in a php editor and there's an error on line 1195 - <div class="slider2"> you need to use single quotes
error_reporting(E_ALL);
-
foreach ($array AS &$a) { $a=array_unique($a); }
you can write that as a function and use an if (is_array($a)) to use it for arrays with more than 2 dimensions
-
use the array_unique() function
-
I realise it won't provide the same satisfaction as doing it yourself, but the phpMailer class by worxware is quite useful and can circumvent many of these email related bugs and let you focus on the application
-
from php.net
$to = 'email@domain.com, email2@domain.com'; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n"; $headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n"; // Mail it mail($to, $subject, $message, $headers);
-
you could have three select elements with year, month, day and then check is_numeric() on each of the fields to ensure validity
<select name='year'> <?php for ($i=1990;$i<2020;$i++) { echo "<option value='$i'>$i</option>"; } ?> </select> //do again for month, day... though month you would have the value as the numeric month and the displayed value as the month name
-
use jquery UI's datepicker rather than letting users type a date... and then you know the format the date will be, if it's not, return an error
-
you need to use the concatenate operator to combine the BCC addresses, or put them into an array and implode like so
$query = "SELECT email FROM zipdatabase WHERE zip = '$ZIP'"; $result = mysql_query($query); $bccs = array(); while($row = mysql_fetch_array($result)) { $bccs[] = $r['email']; } $bccs = implode(",",$bccs); #should echo email1@rara.com, email2@rara.com etc echo $bccs;
-
is something like this what you're after?
you need to enclose the select name in quotes;
echo "<select multiple name='vaccination[]' value=''><option>de hond is behandeld tegen:</option>";
and then when you process the form (this assumes the dog's id is stored in the session under the session variable dog_id
if (is_array($_POST['vaccination'])) { foreach ($_POST['vaccination'] AS $vaccination) { $dog = $_SESSION['dog_id']; @mysql_query("INSERT INTO vaccination SET vaccination_id='$vaccination', dog_id='$dog'"); }
-
change the line to this and post the error it displays
$result = mysql_query($sql) or die ("Error when building the team league table! (function 2)<br/>".mysql_error());
-
yes, the highest id will be the latest.
-
what error is it throwing?
-
you would need to install a java applet or ActiveX controls... can't do it through PHP or Javascript to my knowledge
*edit* quick google found this activeX code
<script type="text/javascript"> <!-- var WinNetwork = new ActiveXObject("WScript.Network"); alert(WinNetwork.UserName); //--> </script>
-
how are you choosing which form to display?
and you're posting it with ajax...?
add "document.formName.reset();" to your validateHeader function to reset the form - where formName is the name of your form
and to have form B display after your submit form B, how are you choosing which form to display? is it posting the form and then reloading the page from scratch? if so use an $_GET variable in the URL to indicate which form it is... i.e. post formB to annual_report_main.php?form=b and then when you load that page, use
if (isset($_GET['form'])) { switch ($_GET['form']) { case "b": echo "formB"; break; case "c": echo "formC"; break; default: echo "default Form A"; break; } }
-
you should separate the functions from the code, and it's the die(); function being called in your 'died()' function which is stopping the rest of the page from showing... try somethign like this
<?php function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "luka@fer-projekt.com"; $email_subject = "Your email subject line"; $error = false; // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { $error_message = 'We are sorry, but there appears to be a problem with the form you submitted.'; $error=true; } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $error_message = (isset($error_message))?$error_message:''; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; $error=true; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; $error=true; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; $error=true; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; $error=true; } #check that errors weren't set if($error) { $email_message = "Form details below.\n\n"; $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); echo 'Thank you for contacting us. We will be in touch with you very soon.'; } }
-
this will add the class to the <div class='homebox'> div...
<?php query_posts('showposts=3&cat=20&orderby=rand'); $i = 0; while (have_posts()) : the_post(); $i++; $class = ($i%3==0 && $i<>0)? "last" : ""; ?> <div class="homeBox <?php echo $class; ?>"> <div class="boxgrid caption"> <a href="<?php the_permalink();?>"><?php the_post_thumbnail(); ?> <div class="cover boxcaption"> <h2><?php the_title();?></h2> </div> </a> </div> </div> <?php endwhile;?>
Troubling ORDERS
in PHP Coding Help
Posted
they're not alphabetical because you're ordering by a numeric value; CITY ID, order by city rather than city id.