Jump to content

grissom

Members
  • Posts

    166
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

grissom's Achievements

Member

Member (2/5)

0

Reputation

  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
×
×
  • 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.