Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Drongo_III

  1. Sorry I completely missed that when I was reading over php.net - and now it all makes perfect sense! Thank you
  2. Hi Guys I was trying to set a class property today in the same way I have for a long time but it didn't work and it made me wonder whether I have been doing something wrong for a while. When i try to set a session variable to a property of the class, as in $sessID below, i get a php error: "unexpected t_variable". I have been staring at the screen for some hours but I cant actually see anything wrong with the line. If I comment out the sessID line and instead set this property in the construct this works fine. So few questions spring to mind: 1) is there some reason you can't set a variable outside of the construct like this? 2) is it best practice to set such variables as part of the construct? 3) Why do all the other variables work fine but not the session one? It may yet transpire the answer to one of these questions is the answer to all Thanks, Drongo class user_admin extends login { public $errors = array(); private $userData = array(); private $changePassword = false; public $sessID = $_SESSION['user_logged']; public function __construct(){ //$this->sessID = $_SESSION['user_logged']; $this->getUserData(); include('/forms/user-admin.php'); } }
  3. Thanks Abra! I will try this tomorrow. See i knew one of clever peeps here would have it down Drongo
  4. Hi Guys This is a bit of a weird one and I wondered if perhaps someone here had experienced this and found a work around. I'm using zip archive on a project at the moment. Basic version of the code is below. When I zip a file and output it to the browser using headers it works fine in the example below. BUT if I try to add a file from another directory, as in the commented out line below, the resulting zipped folder can't be unzipped in windows. When I try I get a "The folder XXXX is invalid" message. I sent the same zipped folder to my htc phone and it opened the zipped folder no problem. The puzzling thing about windows is that it works fine if the image originates in the same directory as the executing script and can be opened no problem. So is this something anyone else has encountered? And how can you get around it? $zip = new ZipArchive(); if ($zip->open('./test2.zip',ZipArchive::CREATE) === TRUE) { //$zip->addFile('../fileUploadLocation/somefolder/image1.jpeg'); $zip->addFile('image3.jpeg'); $zip->close(); echo 'ok'; } else { echo 'failed'; }
  5. Hi Guys Working on a big multi-stage form. The form has multiple stages, each posting to the next. There is currently minimal validation - validation is done via a simple regex which as a minimum allows these chars: a-z A-Z 0-9 - £ As I need to store up all the user data until they complete and it can be passed to the database I am wondering if there is anything in particular I should do, besides the validation, to make sure the data being held in the session is safe? I've read about some exploits via user data in the session but can't say I have an exhaustive understanding of this so any tips are welcome. Drongo
  6. Sorry mate it is just stripping out the regex everytime I try and paste it. I have pasted the code into a temporary repository: http://codetidy.com/5995/ Go there and grab it and let me know how u get on
  7. Sry tried to respond to this post but its not saving my code in the code block. Might be because the line length of the regex I am trying to paste in. :/ I know this is frowned upon but going to try and paste this straight into the message window: <?php $STRING = 'This is a https://www.google.com link'; $linkReplace = "<a href=" . "$1" . " target='_blank'>$1</a>"; // Replacement pattern to create a link $text = preg_replace($RegExp, $linkReplace , $STRING); echo $text;
  8. This should do the job. I got this very nifty regex off someone on here.
  9. Hi Guys Bit of an odd one. I've created a custom 500 error page and my hosting company has told me that they've made the necessary httpd.conf changes. The thing is - how do you simulate a 500 server errror? I've tried throwing an exception but this did nothing. I've also tried breaking a htaccess file but this doesnt display my custom page, which leads me to think that the configuration hasn't been setup properly. But as I'm not sure if this is a valid way to test it I thought I would get some advice. Any helo would be appreciated! Drongo
  10. It would be funny if it wasn't so stupid lol... I will go now and lash myself in the garden to twenty minutes. Sowwy!
  11. Perhaps you can point out where i'm doing it wrong? The below code doesn't work. <!doctype html> <html> <head> <script type="text/javascript"> var mylink; function init(){ mylink = document.getElementById('link1'); alert(mylink.id); myLink.onclick = myFunc; } function myFunc(){ alert('click worked'); } </script> </head> <body onload="init();"> <a href="#" id="link1">Click me</a> </body> </html> But if I replace that init function with a direct call to document.getElement (as per below) it works fine. So I am just trying to understand either what I am doing wrong or whether there is some fundamental precept of javascript i am missing (probable)... function init(){ //mylink = document.getElementById('link1'); //alert(mylink.id); document.getElementById('link1').onclick = myFunc; } And thanks for this mate but this is a different type of event registration. I am trying to work out why the traditional model doesnt seem to work for me
  12. Thanks for that. But it wasn;t so much that I couldnt get the event to work, or that I couldn't register the event in another way. What I was driving at is to try and understand why it works with document.getElementById but not when I simply use a resource (i.e. set a var with document.getElement... and then assign it to the event). Any ideas why that may be?
  13. I may stand corrected here but at least one issue is that you are trying to pass an entire array to your switch statement, which as far as I am aware isn't possible. A switch usually takes a single value to evaluate against. So you might want to do a foreach statement and run the switch in a function that can be called on each iteration.
  14. Hi Guys I have been a jquery junky for a bit too long and neglected much of the raw javascript behind it...hence this simple question. When I try to register an event in the format of : element.onclick = funcName; the only way I can get this to work is with: document.getElementById('elementId').onclick = myFunc; Whereas if I try and give this event a handle (below) it doesn't work at all and I get an 'undefined' error in console even though it plainly is defined. But surely these two statements amount to exactly the same thing? var someElement = document.getElementById('elementId'); someElement.onclick = myFunc; // This doesn't work So what am i missing? Thanks, Drongo
  15. Could anyone help with this one please?
  16. Hello I have a quick question. I want to make a custom 500 error page. I understand this is achieved by tweaking httpd.conf file to direct to a specific file in the event of a 500 error. What I want to know is if I make a html 500 error page should this be located on another server? The logic being that if the server can't render any of the normal pages on a site due to a 500 error why would it be able to render my customer 500 page. Does that make sense? And whats the best practice here? Thanks, Drongo
  17. Worked it out now. Seems you have to declare that the first array level is an array too: var locObj = []; locObj[1] = []; locObj[1]['top'] = 'twinky' alert(locObj[1]['top']); Just thought I would post back in case anyone else gets stuck on something similar. Though why you can't just write it like php is hard to fathom - still that's javascript for ya!
  18. Hi Guys Super simple question. I want to create a multidimensional JS array where I can define the keys. Perhaps my mistake is using similar syntax to php but the following code throws an error in chrome console saying "Uncaught TypeError: Cannot set property 'top' of undefined " Can anyone nudge me in the right direction on this? var locObj = []; locObj[1]['top'] = 200; alert(locObj[1]['top']);
  19. Best way to do it... There are lots of methods for achieving this but all depends on how complex you want to make it. If you need the fields to be draggable or sortable then you may opt for a different option but what follows is a simple example to highlight how easy it is. Just as a quick illustration (and i am typing this directly in so sry if it doesn't work) <form> Country: <input type="text" name="someField" value="WHATEVER" onblur="this.style.border='0px'; setAttribute('readonly','true')" onfocus="this.style.border='1px solid black'; removeAttribute('readonly','0')"> </form>
  20. Your logic should look something like this: if(isset($_POST['email'])) { $to = 'YourEmail@host.com'; $subject = 'Your Subject Line goes here'; $message = $_POST['message']; // 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"; // Mail it mail($to, $subject, $message, $headers); } You can add in additional headers etc. which is all explained here - http://php.net/manual/en/function.mail.php But that should get you started. You probably want a better way of checking if the form has been submitted - i just used $_POST email for an example.
  21. Wouldn't advise using mysql anymore - it's deprecated. Use MySQLI or PDO. Have you tried some debugging. I would suggest some of the following: echo out the crypted password and username after you set them and manually compare them to what you have in your database try tweak your query so you are only selecting the username, then only selecting the password - this might give you some idea of what variable is failing to match
  22. Hi Guys I need to setup a MySQL user account so I can connect (using PHP) both on the server where MySQL resides and remotely from another server (these are load balanced servers). I read a MySQL article here: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html - this seems to suggest in order to do this I would need to setup two user accounts as follows: CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; GRANT ALL PRIVILEGES ON MyDB.sometable TO 'monty'@'localhost' CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass'; I am not overly familiar with creating users so apologies for the noob questions about to follow: Is it correct that I need to setup two users with the same username only one as localhost and one with wildcard to be able to use the database locally and remotely ? Rather than use a wildcard would it be more secure to use the remote server's IP - i.e. 'monty'@'SomeIPaddress'? Do I need to grant privileges on the second user - i.e. 'monty'@'%' . Or does this account inherit the same privileges from 'monty'@'localhost'? I would obviously not grant all privileges either but the above is just for simplicity. Is that all I need to do? Thanks Drongo
  23. Hi guys I implemented the code above as per the solution given but I seem to have a strange issue. when I set outlook 2007 to receive plain text email only and perform a test send outlook seems to ignore the plain text version in the email and simply defaults to a plain text version it seems to derive from the html version. has anyone seen this happen before and is to the code or something to do with outlook?
  24. Ahh I see. I need to go do some reading me thinks! Heard of phpmailer but not used it - probably should check these out but I am the worst person for wanting to do it all myself to learn how it works ha! There's a control freak in all of us I guess Anyway thank you very, very much for the help!
  25. You should probably download an ftp program such as filezilla to push files to your server - never used notepad++ for it but I wouldnt trust the results tbh. Also, to my knowledge, you cannot execute php code without a server. If you want to run php code locally you'll need to download something like WAMP server (http://www.wampserver.com/en/) which you can install and run as a server on your computer. This will then let you execute your php scripts. WAMP is insanely easy to install. Hope that helps!
  • 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.