Jump to content

grissom

Members
  • Posts

    166
  • Joined

  • Last visited

Everything posted by grissom

  1. In your main mysql query where you are getting the records from the database, there doesn't appear to be any restriction against it getting all the records .. if you are looking for one specific record, your query should end something like " ..... WHERE id = '$_GET[id]'"
  2. Okayyyy... the error is line 26 which is $fname = $_POST['fname']; The error is telling you that the variable $_POST['fname'] does not exist by the time you get down to this line Your curly brackets around the if($_POST) { ...} section of code end before line 26, so perhaps you need the closing bracket around the whole section of code like this if ($_POST) { ... ALL your PHP in here, because otherwise it will get executed anyway regardless of POST data or not } If that doesn't work, try changing the line to if (!empty($_POST))
  3. Solved it folks ! I had the line 'cols'=array($basicarray) and of course $basicarray already WAS an array ! so it should have been just 'cols'=$basicarray
  4. The problem is that although no errors are being thrown up, the table is not formatting with the column widths I am specifying As a bit of extra info, here's an example of how I would set up and call the function $data = array(); $data[] = array('Date'=>'12-12-2015', 'Name'=>'Alice', 'Postcode'=>'HG1'); $data[] = array('Date'=>'25-11-2015', 'Name'=>'Bob', 'Postcode'=>'SE2'); $widths = array(100, 120, 60); basictableformat($data, $widths);
  5. Hi guys. This one should be really simple but I've got a mental block on it and would really appreciate some help. I'm using some classes from an existing open source class EZPDF to format a table, and their syntax for doing so is like this (here's an example .. here we take an array called $data with fields 'Date', 'Name' and 'Postcode' and assign widths to the columns) $pdf->ezTable($data,'','',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1, 'cols'=>array('Date'=>array('width'=>120), 'Name'=>array('width'=>100), 'Postcode'=>array('width'=>80)) )); Well, that looked a little bit too much work for my lazy brain, so I decided to extend the class and write a new function which basically read in all the data keys and matched them to an array of widths and then did the same thing. But with more convenient shorthand for me ! So here's how I approached it : function basictableformat($data, $widthsarray) { $basicarray = array(); $i = 0; foreach ($data[0] as $key=>$value) { $widthbit = array('width'=>$widthsarray[$i]); $basicarray[$key] = $widthbit; $i++; } $this->ezTable($data,'','',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1, 'cols'=>array( $basicarray ) )); } However, as you can guess .. this didn't work ! It should be EASY but I've just got a Sunday morning mental block on it. Any help folks is massively appreciated.
  6. From what I can see, it also looks like you need another break in your code <?php $file = fopen("Update/Location.txt", "r") or die("Unable to find file"); $string = fread($file,filesize("Update/Location.txt")); echo $string . "<br>"; switch ($string) { case "Home": echo "I am currently " . $string . ", feel free to contact me whichever way is best for you.<br>"; break; case "Work": case "University": echo "I am currently " . $string . ", the best way to contact me is through email or text message<br>"; break; default: echo "i am currently unreachable <br>"; break; } fclose($file); ?>
  7. w3schools are not bad, and they have a nice friendly style. You can find them here http://www.w3schools.com/php/ but would support quickoldcar's comments, if you want completely accurate up to date info, php.net is the definitive place.
  8. It's a quick and sweet Google search : http://www.html-form-guide.com/php-form/php-form-checkbox.html
  9. Just to clarify your question .. are you looking for some code which will generate a hotmail or gmail type address, or are you looking to generate an e-mail address belonging to the server which your code is sitting on? The former, I would imagine, would be nearly impossible, as there are several hoops to jump through along the way involving captcha codes etc etc. As for the latter, well, it's still not a walk in the park for somebody completely new to PHP, but this might help http://stackoverflow.com/questions/17870117/create-emails-accounts-using-php
  10. No method of validating an e-mail is entirely perfect, but tbh FILTER_VALIDATE_EMAIL is easily likely to be equally as good as any REGEX ideas you'll find on Google (and there are loads of them, as I'm sure you've seen already !) As I understand it, though, as with many other solutions, it is simply checking that the "pattern" of characters that make up the email address conform to the specified rules. It does not test (if I understand it right) that the email address is actually real, nor is there any checking to do with disposable e-mail accounts. In the validation function I wrote for myself, I also included a test for all the popular disposable e-mail accounts (dispostable, guerilla, mailinator etc.).
  11. Have you tried firing up MySQL workbench and typing your query in there to see if it runs okay ? (that's often a starting point for me when debugging). Otherwise, just double check that your variable $SQL is actually what it needs to be.
  12. Just one other way of maybe approaching the problem .... when the user logs in, or starts to fill up a cart, the PHP code generates a "session ID" (think up your own unique way to do this, for example it could be some combination of the login time and the IP address .. or whatever, just use your creativity). Then every time somebody adds something to the cart, you write into a database, using the session ID as a reference. That way, you only need one session variable. At the end, when they want to sum up and pay, just list all the items in the database stored against that session ID
  13. The first car has a choice of 10 drivers The second car has a choice of 9 drivers (the first driver has been assigned) So the number of ways of filling the first two cars is 10 X 9 = 90 The number of ways of filling the first three cars is 10 X 9 X 8 possibilities = 720 .. and so on. You make yourself look a complete p**** with your above comment. I suggest you take some night classes in maths before you get cocky and post stupid insulting graphics
  14. If you have 10 cars and 10 drivers then there are 10! (ten factorial) ways of assigning each driver to a car, This is 3628800 different ways. Read all the drivers into an array called $drivers[] Then read all cars into an array called $cars[] Randomly shuffle the arrays by using the PHP shuffle command shuffle($drivers); shuffle($cars); Now put driver[0] with car[0], driver[1] with car[1] etc etc.
  15. Try this and let me know what happens: $to = [email protected] ; // EDIT THIS TO YOUR REAL EMAIL ADDRESS $from = valid_email_address@the_same_domain_that_your_php_file_is_on.com // EDIT THIS TOO. THE FROM ADDRESS NEEDS TO BE A VALID E-MAIL ADDRESS // IDEALLY AT THE SAME DOMAIN AS YOUR PHP FILE // SO FOR EXAMPLE IF YOUR PHP file is part of www.foo.com THEN YOU IDEALLY NEED [email protected] $subject = "Just testing"; $message = "Hello there, here is a test e-mail"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/plain;charset=iso-8859-1" . "\r\n"; $headers .= "From: " . $from . "\r\n" ."Reply-To: " . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $success = mail($to, $subject, $message, $headers);
  16. @CroNix .. er possibly. But looking at the original code, it looked like the variable called $address was actually the body of the e-mail and the variable called $name was the "from" e-mail address ! at least that how it comes across @stjonesMSI - can you just confirm what you are expecting each variable to mean; the names of your variables are somewhat ambiguous, thanks !
  17. Give this a go : $name = $_REQUEST['applicant_name'] ; $address = $_REQUEST['applicant_address'] ; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/plain;charset=iso-8859-1" . "\r\n"; $headers .= "From: " . $name . "\r\n" ."Reply-To: " . $name . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $success = mail("deleted_for_public_posting_purposes", "Online Job Application", $address, $headers);
×
×
  • 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.