Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,450
  • Joined

  • Days Won

    175

Everything posted by mac_gyver

  1. your two class methods will return an array. it's an empty array if the query didn't match any rows or it's an array of the all the rows the query did match, assuming that you are still throwing exceptions for any errors. all your for(){} and while(){} loop logic, besides not working, is not necessary. you can test if the returned array is empty or not using, well, empty(). you can loop over the arrays using a foreach(){} loop. next, $status_replies_=$project->reply2StatusView($id[$i]); you are running a select query inside of a loop. this is a performance killer due to the round-trip communication it adds between php and the mysql server. for what you are doing, you should run one JOINed query to get the data that you want, then just loop over that data. edit: public function statusView($session_uname,$f_uname) { you are passing an array and an index into your function/method to supply an account name. this is not how to write general purpose code. the function/method expects an account name as in input, that's all you should supply as an input parameter, so that you can reuse the function/method regardless of where the input comes from. the definition should just be - public function statusView($account_name) {. the code inside the function should just use $account_name, and the calling code would be - $status2view=$project->statusView($session_uname[$f_uname]); // supply the account name input, from wherever it is stored
  2. a) are you running the query directly against your database using a query browser of some kind so that you would be seeing any errors from the query? b) what i posted isn't a copy/paste query. you need to adapt it to use your table and column names. you would also need to add in the active=1 logic.
  3. see this link - http://dev.mysql.com/doc/refman/5.6/en/example-maximum-column-group-row.html where what you are doing is getting the maximum note id per group. using the last method shown at that link (left join) the following works (cannot vouch for how efficient it is, but it is fairly easy to understand or modify to use any JOINed table query for the two sub-queries) - SELECT t1.* FROM (SELECT p.*, n.note_id, n.comment FROM prospects p LEFT JOIN notes n ON p.id = n.prospect_id) t1 LEFT JOIN (SELECT p.id, n.note_id FROM prospects p LEFT JOIN notes n ON p.id = n.prospect_id) t2 ON t1.id = t2.id AND t1.note_id < t2.note_id WHERE t2.id IS NULL; this is using simplified table naming with - a `prospects` table with at least an `id` column and a `notes` table with at least `note_id`, `prospect_id`, and `comment` columns.
  4. one would hope that the recaptcha api would return a unique error for each different thing that could go wrong, but perhaps not. the ip address in the data to the api is optional, so if it's not being put into the data, it doesn't matter, but what if it is present and it's not the same value from the client when the client solved the captcha? if the client being used for testing is on the same local network with the server, the ip address that the server gets in $_SERVER['REMOTE_ADDR'] will be a local ip. the ip address that the recaptcha api saw when the captcha was solved would be the public network ip address. try removing the ip key/value pair from the $captcha_params. next, i wonder what happens if you submit the same curl request twice, which would happen if your .php page is being requested twice? a lot of clients request a page twice. perhaps the output being seen is that due to a second request, and since the recaptcha api has already seen and responded to any specific 'g-recaptcha-response' value, perhaps it returns a null in this case? i would add code in your .php page that logs some information (see file_put_contents() with the FILE_APPEND flag) from the client request and from the curl response each time it runs. this will let you see if there are multiple requests being made for each form submission and if the curl response is always the same. you can also try using an 'official' recaptcha php class (there's a link on the recaptcha/google page.) perhaps it is setting curl options that can have an affect (i saw some code that's setting an ssl verify host parameter to a false value.) however, getting a null from a curl request seems more like a communication problem. the url that's being used would require that the server have open_ssl installed. what does the output from a phpinfo() statement show for the SSL entry under the CURL section?
  5. without an ORDER BY term in your sql statement, there is NO guarantee that any particular row of matching data is going to always be the first row. what characteristic does your data have that identifies what order you want the rows from the query to be in and what identifying characteristic or value is there that you can use to not include the one particular row in the result set?
  6. just because the mail() function is returning a true value, doesn't mean that the sending mail server has sent or has any intention of sending the email. some mail servers are configured to return a true value/no errors to php regardless of what happens to the email so as to not allow hackers to use the returned errors to find mail box names... next, the yahoo/protonmail email servers may be doing a more thorough check of the DNS records at your web hosting than what gmail is doing (any chance you are using google web hosting so that sending an email to gmail is coming from a google server and the sending mail server is the same as the receiving mail server?). the ONLY information a receiving mail server gets with any email is the ip address of the server/device the email is being sent from (from the tcp/ip data packets) and information in the email, i.e. the from address. the receiving mail server will use these two pieces of information to try and validate that the email is actually coming from where it says it is by checking the DNS records at the sending ip address and at the domain in the from address. perhaps the yahoo/protonmail mail servers are looking for a secondary piece of information that gmail isn't and something is either missing (missing values usually aren't a problem) or is set incorrectly (incorrect values will get an email discarded.) at a minimum, there should be an SPF DNS zone record at the domain being used in the from: mail header that indicates the sending mail server is authorized to send email for that domain. you can check your DNS records and test your sending mail server for configuration problems at a site like dnsstuff.com edit: if this is for a contact form, where you will always be sending to a single email address, you can use SMTP authentication (i.e. provide the access password for the mail box) against a receiving email address and send the emails directly to the mail server where the email address is hosted at. to use SMTP authentication, you will need to exchange smtp commands with the mail server. the phpmailer/swiftmailer classes handle this for you.
  7. is your code producing any php errors or any oci errors? is your code producing a completely blank page or does anything on the page get output to the browser and its just the query result that doesn't get output? if you read any of the 'help my page/query doesn't produce any output' posts on any of the php programming help forums, you will notice a common thread, displaying php errors and testing for and displaying database statement errors. you must ALWAYS have php's error_reporting set to E_ALL and for development/debugging display_errors should be set to ON. these two settings should be in the php.ini on your development system, so that they will report php parse/syntax errors and so that you don't need to remember to put them into the code you are developing/debugging. all the database statements that can fail due to an error (connection, prepare/parse, query/execute) must ALWAYS test for errors and handle them in a meaningful way. for development/debugging, you would want to display the database error information. next, queries that run successful can still match zero rows and in most cases you should use your database's num_rows function/method (see oci_num_rows()) to test for and handle this case. if your code was already was doing these things, it (your code) would be telling you if, where, and way it is failing.
  8. do you have a specific question(s) about doing this? just listing what you want isn't a question and we are not here to do your design for you, just to answer specific questions you have - see the sticky/pinned post http://forums.phpfreaks.com/topic/20513-read-me-welcome-to-application-design/
  9. re: post #6. there's nothing obvious in the code that would account for the problem/browser difference. if i have time i will investigate the code further. re: post #7. isset() tests if the variable is set or not. the boolean true from the print_r just means that it is set. when it is set, it can have either a false value or it will contain the fetched row from the query, so, adding an isset() around it is meaningless. any chance that in the browser where this works, the browser has been configured to remember passwords and it's actually the browser that's supplying the password and in the browsers where this doesn't work, you are actually typing the password and you are using the wrong one, either because the one that works was originally entered/registered with some fumble-finger accidental extra/wrong characters in it, or you are typing wrong password where it doesn't work? in any case, you need to determine why the query is not matching any rows. here are two things to do - 1) temporarily modify the sql query statement so that it only tries to match the username. if the code then results in a var_dump of the $user variable with the expected row from your database table, that means that the username comparison is working and it's the password that's the problem. 2) echo the md5() hashed password value and see if it is the same as what is stored in the row in the database table. i suspect it is not. i would do this for both the browser where it works and at least one where it doesn't. the echoed hashed value should be the same for all browsers and it should match exactly what is stored in the database table row that corresponds to the username you are testing with. edit: actually, step #1 in the above may not be so temporary. if you switch to using password_hash()/password_verify(), you will need to match the username in the query, retrieve the hashed password and pass the entered password and the retrieved hash through the password_verify() function to see if they match.
  10. does the var_dump($user) show a boolean false at the same time as the var_dump of the $_POST data shows what you posted above? given that your html markup shows classes on everything, i'm guessing you are using some framework/code-generator, which could be responsible for the problem (i.e. double submitting the form, once with and once without values.) if you cannot debug and determine what's going on, it's going to take full disclosure of your code that reproduces the problem, both for the entire form PAGE and the entire form processing code in order to help find what is causing the problem. also, this mess - $uname= htmlentities($_POST['unamel']); $unamel= stripslashes($uname); $pass= htmlentities($_POST['passl']); $pass1= stripslashes($pass); htmlentities() is an OUTPUT function it is used when you send output to the browser. it is not an INPUT function and has nothing to do with values being input to your code. stripslashes() is used when you WAN'T/NEED to strip slashes from the input. neither of these functions should be used in your code responsible for logging in a user. while these two functions are not likely the cause (the different browsers could be sending different character-encoded values for your actual username/password), htmlentities could be altering the value(s) making them different from what was used when registering the username/password information.
  11. 1) what does using var_dump($_FILES["file"]); immediately after the first opening <?php tag (in case some of your code/functions are modifying the value) show? 2) are you sure about the actual php code that's running? a statement like $GetName = ServerName($_FILES["file"]["name"]); could very well account for the symptom you are getting.
  12. the boolean false value is a symptom of a query that doesn't match any row(s), which is exactly what i stated in your last thread for this problem. if your code behaves differently for different browsers, it's likely that your form is invalid markup and isn't submitting what you think (or the user doesn't exist in your database table.) different browsers handle invalid markup differently, so, some may submit form data for broken markup, while other's don't. what does using var_dump($_POST) show for the submitted form data and what is your form code?
  13. rashidpathiyil, your question, How to Create a "action.php" page for HTML Form?, isn't a programming problem. it's a research question based on a lack of knowledge. research questions are things you need to take care of yourself in order to learn enough about a subject so that you can make the attempt at performing a task. a programming problem, which is what programming help forums are for, are what you have after you have written some code and you have a problem or error with it that you cannot solve yourself (though too many people just dump their code on help forums without first making any attempt to learn and fix it themselves.) the www was created for researching information. php was created primarily to process form submissions. there are several 100's of thousands of php form processing examples posted on the www that you can examine to learn the basics of How to Create a "action.php" page for HTML Form.
  14. you may have tried a bunch of things, but if you didn't echo out the sql query statement so that you (and us) will know what it is (which would also confirm that the code where the query is at is running) and check if the query is producing an error or not, you will never narrow down the problem and find what's causing it. it's also possible that your code is inserting a row, but its not where you are looking for it at. that you are specifying the database name in the insert query means that the insert query could be operating on a different database than the one you think it is from the connection code. i tried your last posted code and it did run to send the email, display the success message, and insert the row in the database table. the needed step would be for you to add code that checks if the query is failing or not and if it is failing, what the mysql error is.
  15. you need to form the sql query statement in a php variable, then echo or var_dump that variable so that you know what the sql actually is. you also need to check for and handle any query errors. note: you cannot guarantee that getting the highest id from a database table, incrementing it, and inserting it in a new row in the database table will produce unique numbers. you will eventually get a collision where two or more concurrent instances of your script are running and try to insert the same value.
  16. it's all one statement. it doesn't matter how many lines it's on in the file. or just use arrays for the errors and data and avoid all that typing for each different form.
  17. the biggest issue appears to be that the closing </div> for this - <div class="tab-content">, is not after the end of the tabbed content. the closing </div> is on line 288, which is before the tasks and estatus panes. you also have some extra/mis-matched </div> tags. what exact code are you using to accomplish the tabbing (so that someone here could reproduce the problem using your code without making something up that may not be the same as what you are using) and validating the resultant web page at validator.w3.org would help with things like the extra </div> tags.
  18. except that php variables are parsed and replaced with their value when used inside of an overall double-quoted string or when using heredoc string syntax, resulting in a minimum of syntax/context changes to use php variables as part of a string. concatenation results in far more errors, both php syntax and html syntax (the OP currently is missing quotes around the title=... attribute value in the table header section) for those who don't clearly yet know which of the syntax is there for the php and which is there for the html/css/javascript markup.
  19. this is yet another question we cannot answer, due to the multiple different ways code could be written to accomplish any task, without knowing what the code is. if the code is general purpose and data driven, there will be a definition somewhere (hopefully in a database table) that defines all the form fields and all information about each of them - display legend, field type, required, css style selector, validation rules, ..., that controls the production of the form fields and the processing of any form submission.
  20. your output is probably only showing one line because the html is broken. when you moved the array_sum($arr) from the end of the row to the cell with the tank_name, you commented out the </tr> tag. if you are trying to style a set of items, you would use a css class selector, not an id selector.
  21. what output are you getting from the page? and if it's a blank page, what does the 'view source' in your browser show? next, do you have php's error_reporting set to E_ALL and display_errors set to ON in the php.ini on your development system so that php would help you by reporting and displaying all the errors it detects? you can put these settings into your main file, but if your main file contains a php syntax error, which is typically what causes a blank page, it won't help you because your code never runs in this case to affect the error_reporting/display_errors settings. you also have an error in the database connection code error handling. there's no $db variable being used, so there's no $db->connect_error to use in the error handling. edit: and based on examining the code closer and on the color highlighting, you do have a php syntax error due to putting single-quotes inside of an overall single-quoted string. having php's error_reporting/display_errors set as suggested, in the php.ini on your development system, will save you a TON of time when trying to learn, learn anything new, develop code, or debug code.
  22. you would need to post what your current code is, how the current code is being used in or requested by your page, some example data showing what special characters you are talking about, what output you got from that example data, and what problem, symptom, or error you get in your application due to that output.
  23. see the json_encode() function. it will produce the output you are manually piecing together. make an array of arrays of all the rows, then just use - echo json_encode($your_array);
  24. you need to stop creating new threads for this and read what has already been posted. you were told in the first thread that the code that dynamically outputs the imaged based on the id in the link, isn't the code you need to change. you need to change the code that's producing the links so that it produces a link that contains the highest id.
  25. starting with the line that runs your sql query, the following is all that you need (untested) to produce the result - $result = $conn->query($sql); // run the query $rows = $result->fetch_all(MYSQLI_ASSOC); $data = array(); foreach ($rows as $row) { $data[$row['short_name_i18n']][$row['nickname']] = ($row['combination_exists'] == 1); } if(empty($data)){ echo "Please select again, no players found matching your search"; } else { foreach($data as $tank_name=>$arr){ echo "<tr><td width='167'>".$tank_name."</td>"; // tank name as row label foreach($arr as $nickname=>$element){ // output the data for each cell - you apparently have two images 0.png and 1.png echo "<td><img src='./img/{$element}.png' height='20' width='20' title='$nickname'></td>"; } echo "<td>". array_sum($arr) ."</td></tr>"; } } ?> </table> another recommendation - only SELECT the columns in your sql statement that you are using the data from. based on what you have shown in this thread, the select part of the query only needs to be - SELECT tank_list.short_name_i18n, player_list.nickname, garage_list.tank_id IS NOT NULL AS combination_exists
×
×
  • 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.