Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,451
  • Joined

  • Days Won

    175

Everything posted by mac_gyver

  1. i think you are asking how to extract the (unique) data from your existing database table and insert it into a make table, a model table, and a third table that relates the makes and models? please confirm/clarify?
  2. if you do this using php code, rather than in the query, i would either fetch or convert the $uc_sid values to a one dimensional array of values before the start of the loop (it could contain a substantial number of values, up to and including the entire $sectors array), rather than to repeatedly loop over it inside of another loop.
  3. here's a suggestion that hasn't been made yet - you need to separate the php 'business' logic from the 'presentation' logic on the page. the php code that determines what to do on the page and knows how to retrieve the data from the database should all come first. the result of this code should be php variables that provide the input data to the presentation logic. then you put all the presentation logic last. this includes everything from the html doctype tag, through to the closing </html> tag, and any css and javascirpt. the php code/functions/classes in the presentation logic are only that which knows how to take the data it receives from the business logic and produces the output on the page from that data. the business logic contains NO html, css, javascript markup/tags/code. the presentation logic contains NO database specific statements.
  4. the code you have posted is for processing a form submission. you are seeing the invalid .... message because you are unconditionally running the code when the page is requested and none of the values being tested exist, resulting in a false value for the conditional test that causes the invalid ... message to be output. any form processing code needs to test if the expected form has been submitted before attempting to use any of the form data. you are also seeing the error message at the top-left of the page because you are not outputting it through the template system the script you are trying to use is using to produce the html pages. you cannot simply copy/paste together code without taking into account the methods being used by the code you are trying to modify.
  5. you are mixing different formats for the expire column data. your query is treating it as a mysql datetime or mysql timestamp value, as that is what NOW() returns. your php code is treating it as a unix timestamp, as that is what time() returns. what is the actual data type of the expire column in your database table?
  6. sessions "going away" when navigating between pages or submitting forms is usually due to the host-name/sub-domain (the www.) in the url changing and the session.cookie_domain setting isn't set up to match all variations of the domain name, so that the session only matches the variation of the domain where it was created. this actually results in two different sessions for the visitor. one way this could affect only one location is if they have a common link they were given that they use to access the site, that has one variation of the host-name/sub-domain, but the site itself uses links/form-actions that have a different variation of the host-name/sub-domain. so, what is the session.cookie_domain setting for the site and/or is it redirecting requests without the www. on them to urls with the www on them?
  7. you need to fix several things - 1) you should NEVER open a database connection, run one query, and close the database connection, and since this is a class/method, you are likely doing this in multiple methods in the class, resulting in duplicated code. you should create the database connection in your application code and pass it into the instance of your class. 2) so that the code will function the same, the call-time parameters must be the same for either type of database library functions. what you have shown isn't, since it appears that for the PDO, the $args is just an array of arrays of parameter numbers/values. since the first array element is the 'isiiiss...' type string, why don't you use that in the PDO bind statement to use the correct PDO::PARAM_STR, PDO::PARAM_INT, ... type values? 3) you apparently have a typo in this line - $dbQuery->bindParam(array_values($arg)[0], array_values($arg)[0], PDO::PARAM_STR); that should probably be $dbQuery->bindParam(array_values($arg)[0], array_values($arg)[1], PDO::PARAM_STR); 4.a) the return value must also be the same for either type of database library functions. you are returning an array of objects for the PDO case. you are returning a Boolean value in the case of a prepared mysqli query (see the php.net documenation for mysqli_stmt_execute to see what it returns) and one row fetched as an object from the result set in the case of a non-prepared mysqli query. 4.b) for the case of a non-prepared mysqli query, you would need to loop over the result set, storing the object fetched for each row into an array that you finally return. 4.c) for the case of a prepared msyqli query, if the mysqli_stmt_get_result() function is present (this is both dependent on the php version and if the mysqlnd driver is being used), you can convert the result from the prepared query into a normal msyqli result set and use mysqli_fetch_object() in a loop to build the array of objects that you finally return. otherwise, you will need to dynamically bind each column selected in the query to an array element, fetch each row of data into that array, and store that data as an object into an array of objects that you finally return.
  8. you would leave off the leading % wild-card. note: you can put php variables into a double-quoted " ... " string - $sql="SELECT contact_id, first_name, last_name, church_org FROM ics_data WHERE last_name LIKE '$letter%'";
  9. see this pinned/sticky post - http://forums.phpfreaks.com/topic/150979-this-board-is-not-a-code-repository/
  10. this is a known problem. password reset emails and email notifications are currently not working. sorry.
  11. for both the code examples you have posted, testing if($var), that if() statement is false for an empty array. see this link for how php treates/compares values - http://php.net/manual/en/types.comparisons.php
  12. that particular piece of information is incorrect. there is no session variable in your script by that name. whoever suggested it was just guessing and it's not possible to write code that does what you want unless you have 100% accurate information. the session/logged in code does however set a variable $loggedin = 1; when the $_SESSION['user_id'] is not empty. this is why it is important when programming to actually read the code you are using, rather than to depend on other people to tell you or to guess about things it is doing, so that you don't waste days on a task that only takes a couple of minutes. you didn't however answer any of the questions i asked in the first reply in this thread. does php code even work in the template files where the log in form is at? i'm guessing it doesn't and you must use the template's methods to cause sections to be displayed or not.
  13. what is the context of this html/form? is it part of a template file that allows php code to be used in it or would you have to use the template's own conditional logic? what is the template engine? is it the only thing in a template file so that the entire template itself could be conditionally rendered by the main php code?
  14. this forum is not for finding/requesting scripts. see the pinned/sticky post at the top of this forum. topic locked.
  15. your code looks like it should work. what does a 'view source' in your browser show? if there are empty html-table rows, then it's likely your database table names don't match exactly the $row[...] index names, which would result in php error messages if you have php's error_reporting/display_errors turned full on.
  16. your code works as expected for me, with a slightly different jquery version. are you sure the <img ...> tag you are clicking on has a data-idproduto='...' attribute in it? about the only way you could get an empty $_POST array would be if var idproduto = $(this).data('idproduto'); doesn't result in any value. what are you getting in your browser's console log?
  17. He's already using that.
  18. @Strider64, if you meant the pm from me, you were told not to put links to your site in replies, especially since the OP is already using the jquery timezone plugin and has a specific question about getting the time zone value to use in the php date_default_timezone_set() statement.
  19. you are putting a space on the end of the DB_USERNAME defined constant. if your code (for debugging/learning) was making use the php warning from that statement or the mysqli_connect_error() message you would probably be able to see it in the error message - Access denied for user 'root '@'localhost' (using password: YES) ^ in programming, every character matters and in this case an extra character that's not present in the actual value causes the connection to fail. this is no different than if your code had define("DB_USERNAME", "roota");. that's not what the username is.
  20. the short answer is you don't hide some of the rows that a query returns, you get the query to only return the rows you want. you would take the submitted make value from your select/option drop-down form, and if has a value that isn't isn't the 'make-any' value, use it in a WHERE make = ? clause in your first query, using a prepared query to help prevent sql injection or to prevent any special sql characters in the value from breaking the query.
  21. the code you found that's setting the session parameters is setting the session.cookie_secure setting to a true/1 value. this means that the session id cookie will ONLY be sent to the server when making a https request over an encrypted connection.
  22. there's no need for your days_week table. just use the existing relationship between the day numbers and day names that either mysql or php defines (there's four different choices, pick one, which you are likely already using in your calendar, and use it throughout your code.) next, you should store the day number, not the day name, in your available table. it will take less storage and if you are searching or manipulating the data using the day number, it will result in a faster query than operating on the day name string. your available table has a unique id. you would use that in your update form to identify which row the submitted data belongs with, typically as an array field name index value. since you haven't shown your update form, cannot specifically help you beyond telling you what you should be doing.
  23. create a new test .php file on your server with the following code in it and let us know what output it produced when you run it - <?php var_dump(ini_get('display_startup_errors')); var_dump(ini_get('display_errors')); var_dump(error_reporting()); echo '<br>'; ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); var_dump(ini_get('display_startup_errors')); var_dump(ini_get('display_errors')); var_dump(error_reporting());
  24. data you store should have a unique id, typically an auto-increment column, that you can reference it by. your update form would then submit the unique id/value for each row that was displayed for updating. your update logic would then loop over the data, getting the unique id and the value for each submitted row of data to use in the update query. you would also still need to enforce ownership in the query, by making sure that only rows that the currently logged in user 'owns' can be updated.
  25. you should store the category names in a database table along with an auto-increment id column, that becomes the category_id. you then need to add a category_id column to your videos table and store the correct category_id in it. once you have the category_id column in your videos database table, you would simply GROUP BY category - select count(1) as count FROM videos GROUP BY category_id to get the correct category name, you would write a JOIN query between the videos table and the category table using the category_id column in the two tables.
×
×
  • 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.