Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. try checking the response with the rest of your post data: if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) || $_POST['g-recaptcha-response'] === false){ //<<<--- API Docs state that the reCaptcha populates an HTML POST value with it's response ... }
  2. what have you tried? What do you get if you change the following LEFT join to an INNER join? Also, there is a spurious closing parenthesis ) in the WHERE clause that could be causing an issue. You should wrap all complex conditions inside parenthesis to ensure that the clause is checked accurately FROM dbo.CWAnnouncements Left JOIN dbo.NotificationArchive ON dbo.CWAnnouncements.AnnouncementID=dbo.NotificationArchive.AnnouncementID WHERE (dbo.NotificationArchive.UserID='#GetAuthUser()#' AND dbo.CWAnnouncements.Active=1 AND dbo.NotificationArchive.UserID IS NULL) OR dbo.CWAnnouncements.UserID='#GetAuthUser()#' AND dbo.NotificationArchive.UserID='#GetAuthUser()#' AND dbo.CWAnnouncements.Active=1 AND dbo.NotificationArchive.Active = 1 )
  3. You should be coding temporal functions to use callbacks. If you're not familiar/confident with callbacks have a look here and here (the first one is easier on the eyes, but I find the second uses better language).
  4. if you have sftp access to both servers just use that to copy the file from one to another.
  5. You could try turning $data into an array of lines and accessing the third entry $dataByLines = explode("\r\n", $data); print_r($dataByLines[2]); That's assuming a windows linebreak format...and that explode addresses special char's which I can't remember off the top of my head if it does or not.
  6. I, personally would use sessions, but that's just my opinion, there are arguments to and for each method. If you are most familiar with passing data through the url, then just go with it. Firstly you need to alter all your links to the page to make sure they are passing the variable that you need. //page1.php links: $linkPostfix = "?refPage=1"; //for mobility and convenience make a variable to append the new url variable data ... <a href="function.php<?php echo $linkPostfix;?>">Forward</a> <!-- these will be your new links (assuming the same formatting as your other code) Any decent code editor will change all entries in a single, well formed, search/replace. --> ... //page2.php is pretty much the same $linkPostfix = "?refPage=2"; //obviously this one is 2 instead of one ... <a href="function.php<?php echo $linkPostfix;?>">Forward</a> <!-- again, search and replace should make this pretty painless. --> ... Then, in function.php, use a conditional statement to check the value of $_GET['refPage'] and generate the "Back" link to suit. You can either use if/elseif/else or a switch statement. I'm going to stick on ye olde if. //function.php if(!isset($_GET['refPage']){ //code to perform if no refPage variable is passed - such as a header redirect to a home page or an error message } elseif($_GET['refPage'] == "1"){ $backlink = "page1.php"; // relate a backlink to refPage value of 1 - which we set in page1.php } elseif($_GET['refPage'] == "2"){ $backlink = "page2.php"; //you get the idea } //notice no else - we don't want a "catch-all" value applied to the backlink for values out of range, but if you did want to this is where it would go. /*-------------------------------- //because there is ever the possibility that someone will end up on the page without passing the refPage var, //and because we only set a value to $backlink if refPage is set, then we need to make sure $backlink is set //before trying to render the links, or else the script will get upset --------------------------------*/ if(!isset($backlink)){$backlink="#"} ... //The last thing left to do is change the links on the page to: <a href="<?php echo $backlink; ?>">Back</a> <!-- remember Search and Replace is your friend --> ... // all done. That's pretty much all there is to it.
  7. There are a couple of options using PHP's super-globals. You can pass the previous page through the url and have your destination pick it up with a $_GET request, you can $_POST the info through using a hidden form field and a submit event, you can access the $_SERVER[] array to get the HTTP_REFERER or HTTP_HOST+HTTP_REQUEST_URI or you can set a $_SESSION variable to carry the information through. If you would like help with a specific option let us know which one.
  8. Yes and No. I assume you have a modular connection design in so much as all 1000+ queries are run through the one same piece of transaction code. If that is the case, then you can alter that transaction code to launch a PDO->query() which will accept the same format of sql strings that you are using. This is circumventing half of what makes the modern transaction layers better than the original mysql connector, but the same sanitisation that you have been using should be just as effective as it always was. This means that you will continue to function once mysql is removed from PHP and buy you time to build up those muscles and take on Hercules. You could always look into writing your own automation script for updating query strings and transaction layers. swapping in placeholders based on a preg_replace on $'s in the query string and building statements based around these $ sub strings and their data types.
  9. you would be better off using the loops to create a single query string that you can send to the db.
  10. Here's an update to my code that has some conditional checks in place to stop the empty items: $orderTemp = array(); foreach ($results as $row){ if(count($row) == 3 ){ $orderTemp[$row['Lev1']][$row['Lev2']][] = $row['Lev3']; } if(count($row) == 2 ){ $orderTemp[$row['Lev1']][$row['Lev2']] = null; } } $list = ""; foreach($orderTemp as $first=>$second){ $list .= "<ul class=\"list-unstyled categorychecklist \">"; foreach ($second as $secKey=>$third){ $list .="<li><input type=\"checkbox\" value=\"\"> {$secKey}"; $list .="<ul class=\"children\">"; if(is_array($third)){ foreach($third as $triKey=>$value){ $list .= "<li><input type=\"checkbox\" value=\"\"> {$value}</li>"; } } $list .="</li></ul>"; } $list.="</li></ul>"; } echo $list; Edit : added check to stop warning during third foreach
  11. that's still not 9 seconds worth, 9 seconds to a computer is a long time something else must be affecting the performance. Can you explain how each of your arrays is being created, do you have control over the order of elements?
  12. First, you can deal with any array using a foreach Second - nesting loops is detrimental to performance, especially when you don't break out properly when the desired point is reached. Instead of iterating through to top level arrays and checking values within them you are suggesting that the OP could improve performance by iterating trough all 16 array entries even if the value is found first check. That's just nonsense.
  13. Isn't that excessive overhead for a known, fixed depth, MultiDim Array?
  14. The formatting of the post has thrown what you posted all over the place on my end. Could you just post a describe of your tables, and then an example of what you would like the output to be. p.s. - have you thought about setting up a local development environment that won't cripple your hosting company if you make a boo boo?
  15. there is no way that running that code should take 9 seconds unless your doing it on a 386. either you're not giving all the info or something somewhere is seriously wrong with your setup.
  16. here's a tried and tested answer that's almost the same as what @Ch0cu3r suggested, only real difference is that my code doesn't hard set the output to use "Pets" and that the output is stored in a variable before being rendered to the page. $results = array( array('Lev1'=>'Pets', 'Lev2'=>'Dogs', 'Lev3'=>'Bulldog'), array('Lev1'=>'Pets', 'Lev2'=>'Dogs', 'Lev3'=>'BullMastiff'), array('Lev1'=>'Pets', 'Lev2'=>'Dogs', 'Lev3'=>'Chow Chow'), array('Lev1'=>'Pets', 'Lev2'=>'Dogs', 'Lev3'=>'Cocker Spaniel'), array('Lev1'=>'Pets', 'Lev2'=>'Dogs', 'Lev3'=>'German Shepherd'), array('Lev1'=>'Pets', 'Lev2'=>'Dogs', 'Lev3'=>'Gordon Setter'), array('Lev1'=>'Pets', 'Lev2'=>'Dogs', 'Lev3'=>'American Bobtail'), array('Lev1'=>'Pets', 'Lev2'=>'Cats', 'Lev3'=>'Balinese'), array('Lev1'=>'Pets', 'Lev2'=>'Cats', 'Lev3'=>'Birman'), array('Lev1'=>'Pets', 'Lev2'=>'Cats', 'Lev3'=>'British Shorthair'), array('Lev1'=>'Pets', 'Lev2'=>'Cats', 'Lev3'=>'Burmese') ); $orderTemp = array(); foreach ($results as $row){ $orderTemp[$row['Lev1']][$row['Lev2']][] = $row['Lev3']; //creates a multidimensional array that reflects the hierarchy } $list = ""; //init string variable foreach($orderTemp as $first=>$second){ // start iterating through the top level array (pets) $list .= "<ul class=\"list-unstyled categorychecklist \">"; //create the initial ul foreach ($second as $secKey=>$third){ //start iterating through the second level array (cats and dogs) $list .="<li><input type=\"checkbox\" value=\"\"> {$secKey}"; //create initial checkbox level $list .="<ul class=\"children\">"; // open sub list foreach($third as $triKey=>$value){ // iterate through the third level (names of breeds) $list .= "<li><input type=\"checkbox\" value=\"\"> {$value}</li>"; // create checkboxes for breeds } $list .="</li></ul>"; //close top level checkbox items } $list.="</li></ul>"; //close initial ul } echo $list; // render the output to page
  17. You can use jQueryUI to "pop-up" an html page. That page can have a pdf embedded in it the same as any other...It is possible with a little jiggery-pokery to get what you want. See here: http://api.jqueryui.com/dialog/
  18. I have never known anyone truncate anything other than a table in mysql sql...are you trying to round off the number?
  19. I just have to say, if you have a client then you are getting paid for this. If you are getting paid for this then you have pitched yourself as someone who can do this job. You have had code for free for something you are going to profit from (and have since asked for more) that get's you pretty close to where you need to be, if you can't take that and adapt it to what you need then you really shouldn't be taking on these clients, or asking people here to do your job for you for nothing. What's with people these days?
  20. some idea of what you mean by "not working so well" would be more than a little helpful. Also, a Describe of your table would be a big help as well.
  21. do either of your included files have any mysqli calls in them?
  22. I absolutely love heredoc's. Seriously, can't get enough of them. have a look as this re-write of your form loop: <?php $formOut = ""; foreach($rows as $row){ $formLine = <<<FORMLINE <div class="t"> <table class="table2"> <tr> <td class="table2">{$row['id']}</td> </tr> <tr> <td><img src="images/{$row['photo']}" alt="" width="130" height="130" /></td> </tr> <tr> <td> <textarea class="js-copyfilename" readonly="readonly" >{$row['photo']}></textarea> <button class="js-copyfilenamebtn">Copy Filname</button> </td> </tr> </table> </div> FORMLINE; $formOut .= $formLine; }; I find that it's much more readable without all the php opening and closing tags all over the place. That said, what exactly are you looking to achieve here? If you're trying to push info into the clipboard (as it looks like you) then you can't just pass it a raw array - it's not going to have access to the array contents. You would need to serialize the array then pass the string to the clipboard, but then the output when someone pastes the content back out will look weird to them. You could try to append the values to the clipboard in a custom format by calling a paste back into a temp variable before each "copy" and then append the new data and pass it back as the value to the copy call - but I don't even know if this will work without a hidden text-area to act as a collection point for the Copy call. Another way would be to change your whole layout so that the user sees and is aware that they are adding each photo location to said textarea with the button click (even giving the option to remove should they choose?) and provide a separate button to copy this text area to the clipboard. This would provide more control to the end user, but more click's required as well.... So it really depends on your own preference and the target audience of the site. How would you like to go forward?
  23. there are floods of solutions to this, just searching for the "You don't have permission to access /phpmyadmin/ on this server." part produced the following as the top result: http://stackoverflow.com/questions/8366976/wamp-error-forbidden-you-dont-have-permission-to-access-phpmyadmin-on-this-s
  24. Don't know of any personally, but if you do a web search of "xmpp server for php" you should find something that will fit the bill.
  25. you're welcome, glad I could help.
×
×
  • 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.