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. For my two cents, yes is most *definitely* can be done with PHP, in fact this project is bowling straight onto PHP's bat. As quickoldcar has mentioned, you'll need to partner it up with a database eg MySQL or even a flat file. But again, this is absolutely no problem at all for PHP Just a word of caution though ... this is not an insignificant project, and it will take rather a bit of time to put together especially if you are a newbie, so you need to carefully manage your expectations. However, this could be a *perfect* project to use to learn PHP! I learned all my PHP from doing small practical projects, slowly building up as I went along. Quickoldcar has given you some great tips and links to get you going. You would also find it beneficial to have at least a basic working knowledge of HTML and some javascript and CSS would not go amiss either if you want it to look really snazzy. GOOD LUCK !!
  14. Oops, that should be ID="myresult" not NAME = "myresult"
  15. I've not tried this out and it's late in the evening, so if this is a dumb suggestion, then apologies and I'm sure someone will put me straight before too long but .. how about something looking like PHP : echo ($result) ? '<INPUT TYPE = "HIDDEN" NAME = "myresult" VALUE = "1">' : '<INPUT TYPE = "HIDDEN" NAME = "myresult" VALUE = "0">'; This will write a hidden input field into your html which can be read when the page is loaded in your HTML : <BODY onLoad = "check_the_error(document.getElementById('myresult').value)"> when the page is loaded, a javascript function is called, passing the value which was written by the PHP then some javascript somewhere in your header : function check_the_error(myerror) { if (myerror == 1) etc etc etc pop up the window, put your code here ...... etc. } note : I may have picked up the wrong end of the stick, if so, sorry folks
  16. Hmm, I don't want to put words in rwhite's mouth, but I think he was asking ... if you add the line : echo $connStatus; immediately after your block of code above, what does it say that $connStatus is equal to ? I don't know enough about what is in the rest of your code or not, but from the bit I've seen, I'm wondering if your query should go something like $sql = "SELECT * FROM encounter WHERE id='1'"; $result = $connect->query($sql); while ($rowOfData = $result->fetch_row() { // whatever .. }
  17. 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
  18. why not just use explode to separate the sentence into an array then just run through the array changing every odd (since the array starts at zero) word. Bit of pseudo code : $words = explode(" ", $sentence); for ($n = 0; $n<=length($words)) { if ($n is even) echo $words[$n] else echo 'MOD'; }
  19. 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.
  20. Try this and let me know what happens: $to = your_name@wherever.com ; // 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 me@foo.com $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);
  21. Just to add my two cents, I agree with QuickOldCar and rwhite. OOP can be extremely useful down the line, but not necessary to get you off the ground, particularly when you're writing all the code yourself, and for many jobs I still use functional coding when OOP is (to use rwhite's phrase) 'overkill'. (which for me is most of the time!) I come across OOP most of all when I'm working on a project where many different programmers are involved, so if that's a possibility for your career path, then it is worth it from that perspective.
  22. Not sure if I fullyunderstand the question ... but I think what you would need is to put the 5 text boxes and 2 list boxes into a <DIV> with the property "style=visibility:hidden;" use an onChange event with your original listbox to make the <DIV> visible if the certain listbox item is selected. Put the hidden <DIV> inside your form and all the data within it will be submitted along when the form is submitted
  23. Temporarily put in a debugging statement echo 'Login = '.$vlogin.' password = '.$vpassword; just before setting up the connection string. This will allow you to check that you are setting up the right connection string
  24. Try this http://php.net/manual/en/datetime.sub.php but be careful if you are subtracting time around the switchover of daylight saving and read the notes on the page carefully. Good luck !
  25. @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 !
×
×
  • 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.