Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. you see now what the error suppression character was doing?.... hiding an error from you... the right syntax is: bool mysqli_select_db ( mysqli $link , string $dbname ) in your code should be mysqli_select_db( $link, $database)
  2. could be in this way: $APPLICANT_TO_COMPLETE_FirstName = mysqli_real_escape_string($link, $_POST['APPLICANT_TO_COMPLETE_FirstName']); for each $_POST field that you will pass to the $query string that I show in my previous post... so obviously must be before your INSERT query string.
  3. from this line @mysqli_select_db($database, $link); take out the error suppression character (@) ... it will hide possible errors at that level... is better to find the errors and solve'em instead to hide'em. for debugging is better if you take out the SQL string from your mysqli_query() like this: // This line has been copied just in the way that you it now, but as been said... you must run mysqli_real_escape_string() in all the $_POST fields $query = "INSERT INTO Driver_applicants (FirstName, LastName, Applicationdate, Phone, AltPhone, DL, StreetAddress, City, State, Zip) VALUES ('$_POST[APPLICANT_TO_COMPLETE_FirstName]','$_POST[APPLICANT_TO_COMPLETE_LastName]','$_POST[DateofApplication]','$_POST[APPLICANT_TO_COMPLETE_PhoneNumber]','$_POST[APPLICANT_TO_COMPLETE_SecondaryPhone]','$_POST[License1]','$_POST[APPLICANT_TO_COMPLETE_CurrentAddress]','$_POST[APPLICANT_TO_COMPLETE_CurrentCity]','$_POST[APPLICANT_TO_COMPLETE_CurrentState]','$_POST[APPLICANT_TO_COMPLETE_CurrentZip]'"; // echo your string during debugging to be sure you are trying to execute the right sentence (you must comment the echo line after your finish your debugging) echo $query; // Is the query string OK... then execute it $result = mysqli_query($link, $query);
  4. No... I meant something like this: $mysql_query = "INSERT.......<rest of your sentence here> .... "; even though fixing that line is just the tip of the iceberg... your code has many more issues... for start: - in your initial code, this line $server="XXXsitenamexxx:3307; is missing the closing quote (or it is a typo?) - mysql API (the one that you are using) is already deprecated, you should be using mysqli API or better PDO API - You should never pass directly to your SQL sentences input from the user (in this case all the $_POST values), your should sanitize every input and/or use prepared statements to prevent SQL Injections (google that), and here in the forum there are 1000's of post showing different ways to sanitize input ... either using mysql_real_escape_string() or type casting or both depending on the expected data type for each $_POST value, but as I said before the better option is to use prepared sql sentences. In the meantime you learn some of this will help others to help you if you post the exact error that you are getting... "not working" or "is syntax error on line xx" doesn't help much
  5. you definitively need a better editor... this line is evidently wrong and the one causing (most likely) all the subsequent errors that you are getting... a good editor show in color immediately the problematic line. You are missing the enclosing double quotes for the string. For editors... well is a bunch of decent ones... PhpStorm is one of them
  6. you have to contact your actual hosting provider (siteground?)
  7. if your script was working before you move to the new ISP your best bet is call them and ask for the details of how to use their smtp email service and how to configure it. In your script (first one) you are using unauthenticated SMTP setup... probably your ISP require it to be authenticated... PhpMailer has a test folder with examples where you can see the setup details, but ask your provider first.
  8. Yes .. kicken is correct.... should be $connection...as it is show in my last example (my mistake in the previous post)... fetching is not necessary
  9. the last code that you posted is different to the one in your first post... you have a new (commented) while loop here why?.... where exactly are you running your second query?... post your updated and complete relevant code. The code suggested works fine on my side to solve the "out of sync" issue after a SP call. Here is a complete working example that you can follow <?php // Define how to display/report errors ini_set("display_errors", "1"); error_reporting(E_ALL); /*** mysql hostname ***/ $hostname = 'localhost'; $username = 'xxxxx'; $password = 'xxxxx'; $dbname = 'xxx'; /*** create a new mysqli object ***/ $link = new mysqli($hostname, $username, $password, $dbname); if (mysqli_connect_errno()) { printf("Connection failed: %s\n", mysqli_connect_error()); exit(); } /* Stored Procedure to be executed*/ $query = "CALL Mq_Test1()"; /* Send query (execute the stored pocedure) */ if ($result = mysqli_query($link, $query)) { /* Fetch the results of the query */ while( $row = mysqli_fetch_array($result) ){ $data[] = $row; echo ($row[0]. "--------- SR. " . $row[1] . "<br>"); } do { mysqli_next_result($link); } while (mysqli_more_results($link)) /* Display results of the SP */ var_dump($data); /* Define a Second Query */ $query2 = "SELECT * FROM test1"; $result2 = mysqli_query($link, $query2) or die("Error:" . mysqli_error($link)); while( $row = mysqli_fetch_array($result2) ){ $data2[] = $row; } /* Display Results from second query */ var_dump($data2); /* Destroy the result set and free the memory used for it */ mysqli_free_result($result); } /* Close the connection (Not really neccesary)*/ mysqli_close($link); ?>
  10. test this... after your first while loop.. //Transfer the result to an array while ($row = mysqli_fetch_array($page_set)){ $page_list[] = $row; } add this lines: do { mysqli_next_result($page_set); } while (mysqli_more_results($page_set)); alternatively an IF should have the same effect: IF (mysqli_more_results($page_set)) { mysqli_next_result($page_set); }
  11. Thanks for the clarification kitchen... clearly I misunderstood the objective .
  12. just to satisfy my curiosity... given the example data that I did provide before: Patients: mrn name others1 1 'name1' 'xxx' 2 'name2' 'yyy' Obs: mrn par time_recorded others2 1 1 2013-06-03 16:29:35 'a' 1 2 2013-06-03 16:29:51 'b' 1 6 2013-06-03 16:30:05 'c' 1 7 2013-06-03 16:30:18 'd' 2 8 2013-06-03 16:32:30 'e' 2 2 2013-06-03 16:32:42 'f' 2 7 2013-06-03 16:32:51 'g' 2 5 2013-06-03 16:33:03 'h' could you show us which was the expected results?... asking because your last sentence "so any record with a par>6 showed up even if that was not the most recent par score for that mrn." is kind of confusing and not coincident with the results that I got.. the results that I got from the proposed query are: 1, 'name1', 'xxx', 1, 7, 2013-06-03 16:30:18, '' 2, 'name2', 'yyy', 2, 7, 2013-06-03 16:32:51, '' and they are not showing every record with par > 6 ...look the results for the mrn=2... it is showing exactly 1 record which is the most recent par score > 6 isn't? maybe I misunderstood your objectives?
  13. well... if you are not looking for a matching record of those category/subcategory numbers in the table that could contain them how are you expecting to get a different result of what you have now? do you have a category/subcategory table or not?
  14. that is not how/when you should use mysql_real_escape_string(); it should be used over parameters variables that you are going to use in a query... if you query doesn't have any then don't use it.
  15. no need to re-invent the wheel.... google "free asset management software" and you will find many to pick
  16. every one around here try to HELP you with your code... therefore show what you have so far and where are you stuck... I'm guessing that you know how an UPDATE works right?
  17. Post the code that you have and explain clearly what means "still not working"
  18. mastubbs, on 03 Jun 2013 - 3:15 PM, said: This should fulfill all the requirements: Test data: Patients: mrn name others1 1 'name1' 'xxx' 2 'name2' 'yyy' Obs: mrn par time_recorded others2 1 1 2013-06-03 16:29:35 'a' 1 2 2013-06-03 16:29:51 'b' 1 6 2013-06-03 16:30:05 'c' 1 7 2013-06-03 16:30:18 'd' 2 8 2013-06-03 16:32:30 'e' 2 2 2013-06-03 16:32:42 'f' 2 7 2013-06-03 16:32:51 'g' 2 5 2013-06-03 16:33:03 'h' SELECT patients.*, obs.* FROM patients JOIN obs ON patients.mrn = obs.mrn JOIN ( SELECT mrn, MAX(time_recorded) AS maxdate FROM obs WHERE par > 6 GROUP BY mrn ) AS b ON obs.mrn = b.mrn AND obs.time_recorded = b.maxdate;
  19. what Barand has been suggesting you (and he even wrote the model and the query for you) should be your starting point before to move forward with any other line of code.... if you say that you changed your tables show what they looks like by now.
  20. do yourself a favor and read the examples in the manual, after do that thoroughly you should be able to apply those examples to your case http://www.php.net/manual/en/mysqli-result.fetch-assoc.php Notes: 1) Example#1 and #2 are just 2 different ways to write the code... the results are the same. 2) In the link you also will find a lot of other mysqli functions, you should read some (or all) of them to broad your options/knowledge. 3) mysql and mysqli (with an i at the end) are 2 different API's , they should no be mixed in the code, and in top of that mysql (without the i) API is already deprecated and should not be used at all... use mysqli or PDO API's. 4) Finally... looking some of your previous post... don't copy and paste blindly the code that others forum members provide to you (some are just incomplete and good for nothing else than confuse you more).
  21. none of those format looks like the one that is showed in the php manual... read it again.... or you can try http://www.php.net/manual/en/mysqli-result.fetch-assoc.php too
  22. that is not an error... is just the result of the printf() that you have after the IF... problem is that immediately after you are trying to "echo" a result set (echo $result) .. what you have to do is fetch the result and then echo your "value_sum" value.
  23. 2 questions: - what is the result of this sentence when you run it in your mysql client (phpmyadmin maybe?)... post back the results. EXPLAIN SELECT accounts.account as Account, count(distinct activities.contactid) as Users FROM accounts LEFT JOIN activities ON activities.accountid = accounts.accountid WHERE completeddate >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY AND completeddate < curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY GROUP BY accounts.account; - which are the defined Indexes for your tables accounts and activities
  24. No?.. then you are only giving half or less of the advice to the user... we are supposed to came here to offer professional advice to new users ... telling half of the tale, even realizing that the user is doing things incorrectly or that could cause him trouble in the future is not completely professional IMHO ... your millage can be different. which is EXACTLY what I did say in my first post. anyway... I think that the user has enough information already... point closed for me.
×
×
  • 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.