Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,353
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. did you actually try? the + in the link is the encoded space (because space characters are not valid in links). the + will be automatically converted by php (it does a urldecode on $_GET data) to a space and using the value in a database query will work. you could always do what i suggested, which will eliminate the problem of trying to pass a space in the link -
  2. a) what have you tried? all you did is post what you want. we can only help you with your php code (which is the point of the php coding help forum section) once you have made an attempt and have code to post, along with any errors or symptoms you got from that code that you cannot resolve yourself. b) for a html template code/file there's no need to individually print each separate line of output. you could use one overall print/echo statement with one initial and one final " or just use the herdoc syntax, and if this is all just static html/css/javascript markup with no php variables in it, there's no need to use a print/echo statement at all, just make your html inline by putting a closing ?> tag, followed by your html, then put an opening <?php tag. any inline html is parsed by php and encapsulated for you using a php T_INLINE_HTML token and is output verbatim when executed by php.
  3. the href='...' attribute in the link is missing the closing ', which is probably breaking the rest of the html on the page. use the following inside the loop - $u = $rows['aquaticCenterName']; $v = urlencode($u); // since this is a text name, make it url encoded $result_tb .= "<a href='reviewResults.php?aquaticCenterName=$v'>$u</a><br>"; i would use the id, not the name, as the value being put into the link - reviewResults.php?id=123 and you can simplify the multiple col LIKE '%$e%' OR ... term in the query to be - $query = "SELECT aquaticCenterName FROM reviews WHERE CONCAT_WS(' ', aquaticCenterName, town, county, country, rating) LIKE '%$e%'";
  4. the problem is because your closing </option> tag is actually an opening <option> tag.
  5. 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?
  6. 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.
  7. 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.
  8. 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.
  9. 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?
  10. 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?
  11. 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.
  12. 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%'";
  13. see this pinned/sticky post - http://forums.phpfreaks.com/topic/150979-this-board-is-not-a-code-repository/
  14. this is a known problem. password reset emails and email notifications are currently not working. sorry.
  15. 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
  16. 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.
  17. 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?
  18. this forum is not for finding/requesting scripts. see the pinned/sticky post at the top of this forum. topic locked.
  19. 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.
  20. 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?
  21. @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.
  22. 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.
  23. 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.
  24. 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.
×
×
  • 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.