Jump to content

kalster

Members
  • Posts

    104
  • Joined

  • Last visited

Everything posted by kalster

  1. ty cyberRobot, that function example worked perfect.
  2. Yes, I am asking for help. code, url, ect.
  3. i need to change the color of a word in a string where the word is unknown (from $_POST) and may have one or more uppercase chars. code please.
  4. Yes, you are correct, i forgot the mysql syntax. thank you.
  5. I have noticed that some versions of mysql, the code below needs a ";" at the end of each line while other versions work with a "," and the end of each line. At what version of mysql did that change take place? $mySQL = "alter table users add `username` varchar(20) not null; add `location` varchar(100) not null; ";
  6. Actually, i would like the line to be <p>example</p><br />
  7. I have a line of text like this... <p>example<br /><br /><br /></p><br /> where the number of br tags before and after the </p> tag are unknown. I need the line displayed like this... <p>example</p><br /><br /></br /><br /> I need it in the preg_replace, where the part of the line begining with <p>example is untouched. Thank you in advanced.
  8. No. Between < and >. After searching for a few hours I just found a solution to this problem. preg_replace('/br\s\s+/', 'br ', $text);
  9. Is there a way to remove the white space seen between <br > or other html tags using preg_replace or something?
  10. That gives me the user with the highest post count. What i need is the post count of the user that posted the most.
  11. I have a mysql table like the following. post | username ______________ post1 | username1 post2 | username2 post3 | username1 I need a mysql count or max query that would get the highest post count of a user. At the table above, the post count would be 2 because username1 posted two times. Both the post and username data are unknown.
  12. using php, how to delete values from an array and place those values in another array. Is it possible to take an array like this... Array ( [0] => Array ( [0] => var1 [1] => 1 [2] => var2 [3] => 2 [4] => 3 ) ) and make two arrays like this... Array ( [0] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) Array ( [0] => Array ( [0] => var1 [1] => var2 ) ) The word "var" inside of the array does not change value but numbers can change values.
  13. The ? place-holder worked with a php for loop at bindParam.
  14. with php, I think i can get the total count of $key from an array that is used in implode(). if not, then i will try your code. i will let you know tomorrow if the code works.
  15. That cannot work because how many "?" is undetermined and the range is not known. the range can be anything from one onward. the query is "SELECT". is "select" safe from injection when not using a bindParam?
  16. yes, but how to insert :word1, :word2, ect, in the sql query and first parameter of bindParam?
  17. yes, i understand the place-holders. but the place-holders code cannot be manually done. :words1, :words2, needs to be from an php array, if possiable. then $stmt->bindParam(':array', $key), as an example.
  18. is this select query code safe from injection? try { $stmt = $db->prepare("SELECT * FROM posts WHERE key=$key"); $stmt->execute(); $row = $stmt->fetch(); } notice there is no bind. $stmt->bindParam(':key', $key); the reason i am asking is that i have many $key variable in the query and i do not know how to use bind in a query such as this... SELECT count(*) FROM posts WHERE MATCH (file) AGAINST ('$key' IN BOOLEAN MODE) OR MATCH (user) AGAINST ('$key' IN BOOLEAN MODE) the $key is not an array and the $key does not change it's value.
  19. thank you. and also, at first i thought that was the actual code. I made a mistake and copied the wrong $sql. i have four $sql, each going to the same pdo code and based on a condition.
  20. the variable $words could contain any one word and without numbers in it. Also, the full query has more than one :words in it. the query with many $words in it gives no errors
  21. PDO::ATTR_EMULATE_PREPARES, i tried 'true' and still the same error. SQLSTATE[HY093]: Invalid parameter number $sql = "SELECT count(*) FROM posts WHERE MATCH (comments) AGAINST (:words IN BOOLEAN MODE)"; $stmt = $db->prepare($sql); $stmt->bindParam(':words', $words); $stmt->execute();
  22. I already tried that but it's still not working.
  23. with php pdo, the bindParam is not working. The query outputs :words and instead of the $words value. How can i get this code working? $sql = "SELECT count(*) FROM posts WHERE MATCH (comments) AGAINST (':words' IN BOOLEAN MODE)"; $stmt = $db->prepare($sql); $stmt->bindParam(':words', $words); $stmt->execute(); which code example is more safe? The code below now has $words instead of :words but is missing bindParam. $stmt = $db->prepare(SELECT count(*) FROM posts WHERE MATCH (comments) AGAINST ('$words' IN BOOLEAN MODE)"); $stmt->execute(); $words is passed through both php $_get and $_post
  24. i solved the problem by using this code below the connection try-catch code $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  25. this code is included once every php page and at the top of that page. no other page has a connection code in it. The prepared pdo statements follow this connection code. this connection code does not give any errors. try { $dbh = new PDO("mysql:host=$host; charset=utf8", $username, $password); $dbh->exec("CREATE DATABASE `$name`"); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } catch(PDOException $e){ echo $e->getMessage(); }
×
×
  • 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.