Jump to content

ajoo

Members
  • Content Count

    709
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ajoo

  • Rank
    Prolific Member

Recent Profile Visitors

6,562 profile views
  1. ajoo

    convert a query into one using joins

    OK, I got it. Thanks !
  2. Hi ! I have a query select @rownum:=@rownum+1 as row, tbl_country.Level, tbl_country.TimeOfLogin, register.email, tbl_country.SessionStatus FROM tbl_country, register,(SELECT @rownum:=0) r WHERE tbl_country.UserLogin = ? AND (tbl_country.UserLogin = register.Username) order by row desc limit 1; that works great but I want to change this to use JOINS. Please can someone show me if and how that can be done. I am not sure how and where to place (SELECT @rownum:=0) r in the query with joins. I have tried but it fails each time. Thanks all !
  3. Hi Benanamen ! Thanks for the response. Please bear with me for a day or so while I am doing a quick run through of my code. I'll come back and revert shortly. Meanwhile, here's a link, in case you would like to check out the near same discussion earlier on this topic. https://forums.phpfreaks.com/topic/301981-query-woes-confused/ Sorry for this delay. Thanks.
  4. SIr, The following query however fails to give the number of affected rows. SELECT table_A.uid, table_A.pole, table_A.act as Status FROM table_A UNION SELECT table_B.uid, table_B.pole, table_B.confirm_A as status FROM table_B UNION SELECT table_C.uid, 'User' as pole, (table_C.confirm_A + table_C.confirm_B) as status FROM table_C; There are about 9 rows that are actually formed so I wonder if that is the same as rows affected. Is there a way to find the number of rows formed from the above query ? Presently I encompass the above query with an additional SELECT COUNT(uid) FROM { }bb; which provides the rows that are available as 9. Running the 1st query is faster in this case. I was wondering if I could do without the COUNT(uid) thingy ! Thank you.
  5. ajoo

    Errors turned up by code analyzer.

    Hi all ! Just nudging this once again in hope of some more replies and thus some more information on this , I think, rather critical issue, which I am sure lots of coders become aware of rather late in the day !! Thank you all !
  6. No sir, I hadn't. 🙏Thank you Guru Barand !!
  7. Hi all, Does the statement "CREATE TEMPORARY TABLE temptab as SELECT ... " provide some sort of a return value to check the null/number of rows in that table? Running the same in phpadmin definitely gives the number of rows affected but i don't know how to tap into that value. I tried using the $stmt->bind_result($count); after executing the query thinking it might be the same as the Select query but that returns no value while my table has about 7 rows generated. If someone can show how, if the value can be retrieved. Thanks.
  8. ajoo

    Values not passing to form?

    Sorry, My suggestion is incorrect. I did not take a closer look. Kindly discard the previous reply.
  9. ajoo

    Values not passing to form?

    You are using $item_Annual at one place and $itemAnnual at another.
  10. ajoo

    How to short hand this

    A simple for loop would do the trick.
  11. ajoo

    Errors turned up by code analyzer.

    Hi NotionCommotion, The code analyzer I used is codacy. It's a static code analyzer. I do not think it is using any framework and I am not using any framework for my code either. I have never used any autoloader ever & have no idea about it. I have also never tried composer either. Are these not to be used with frameworks ? Or can I use them in my project which uses no framework or OOPS? If so , then a small example of their usage would be great and get me going. $_POST = array(); $_SESSION() = array(); I have used these just before destroying a session and logging out a user out. mysqli_close. I have used prepared statements throughout. Thanks for the response. I hope some more inputs on this will follow till something concrete can be used to replace the faulty code or it be proved that some of the errors may be superfluous & the code may be used safely as is. Thanks !
  12. Hi all ! I just passed my code through an analyzer and it showed that a lot of it was not following best practices. Some examples are below: 1.Direct use of $_SERVER Superglobal detected. if($_SERVER['REQUEST_METHOD']==="POST"){ if(!isset($_SESSION)) sess_start(); if(isset($_SESSION['timeout'])){ $_SESSION['user']=$user; 2. Direct use of $_POST Superglobal detected. if(isset($_POST['submit']) && $_POST['submit'] ==='Logoff'){ $_POST = array(); $usertype = fcheckRecruiter($_POST['usertype']); and many more like these concerning the use of SUPERGLOBALS. 3. Discouraged functions : header(), session_unset(), mysqli_close(), session destroy() & require_once to name a few besides a lot of other common php functions. header ("Location: donepage.php"); session_unset(); mysqli_close($link); session_destroy(); Well the question is obviously how to tackle these. The surprising part though is that prior to checking the code by an analyzer, I had no clue, like many other coders on this forum perhaps, especially the newbies, that my code was flawed or at least not following the best practices. I never found a single piece of code on the net, in examples, even in examples in the PHP manual that showed the correct usage of these as per best practices. The most surprising of these were of course the SUPERGLOBALS since they are used everywhere and by almost everybody. Googling the internet shows that hardly anyone is clear about these. People are debating on the direct usage of suberglobals where they are used for checking the existence of the variable. So it's all very moot and very grey it seems. Then there are common functions some of which i mentioned above. For example how would I reset the super global $_POST if not by setting it to a blank array? $_POST = array(); Why are these functions, enlisted above, being discouraged from use and what and how should the alternate functions be used ? How to achieve the same functionality in an alternate way? For the use of superglobals I found that it's proposed to use the filters or filter functions to sanatise or validate the input. If i recall correct, Guru Jacques strongly advised against sanitizing any user input. While I can understand validation of user input, sanitization of it seems to be wrong ?? I would be very grateful if someone can shed some light on these very basic and important questions and provide, if possible, some examples of the correct method of using these in code. Thanks all !
  13. Hi, Is this renark fellow hacking or attempting to hack the forum or what ??? I hope not. Thanks
  14. ajoo

    Best approach to send complex data to the server

    Hi ! What you guys are saying is that it is possible to submit form data to a server using a method other than GET OR POST submit. Would you please confirm if you are referring to submitting the form data using JSON format via an AJAX request using JS or JQ OR is this something else ? Thanks.
  15. Hi requinix, Oh great ! I wish you had told me in #7 to replace session with get, that would have solved it. tI did occur to me to do so, but then I thought choosing $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] was a better option because here I got the complete URL for comparison. Simply using the GET can be manipulated because then someone can send $_GET['childprints'] from a different page and trigger the PRINT menu. However you said that SERVER_NAME and REQUEST_URI was not a good idea. I wish you would tell me why that is not a good idea. In any case I have dropped using the print menu altogether and have instead created a PRINT button on childprints which would eliminate the need to go this route altogether. However I thank you for the discussion which is always there for learning. If you can answer the last question ( requested as a wish above ) I would be grateful. Thank you.
×

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.