Jump to content

westman

Members
  • Content Count

    591
  • Joined

  • Last visited

Everything posted by westman

  1. westman

    array in mysqli query

    $uniqueValueArray[] = $mainRow; // my array $sql = "SELECT id, text, date FROM text WHERE id='My Array' ORDER BY id DESC $limit"; $query = mysqli_query($conn, $sql); How do I make a query look for an array?
  2. westman

    array in mysqli query

    Thank you. Last question. If I have my usual $conn = new mysqli($db_host, $db_username, $db_pass, $db_name); in an external file would it be a problem if I add $conn_pdo = new PDO("mysql:host=$servername2;dbname=$dbname2", $username2, $password2); in the same file?
  3. westman

    array in mysqli query

    I removed one LIMIT and it is okay now. how do I close the PDO query and and connection?
  4. westman

    array in mysqli query

    this is my output from print_r($stmt);. PDOStatement Object ( [queryString] => SELECT id, main, id_from, id_to, pm_subject, pm_text, pm_date, pm_open FROM text WHERE id IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ORDER BY id DESC LIMIT LIMIT 0,10 ) Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0,10' at line 1 in /home/outlinetalent/public_html/t_all.php:86 Stack trace: #0 /home/mysite/public_html/file.php(86): PDOStatement->execute(Array) #1 {main} thrown in /home/mysite/public_html/file.php on line 86
  5. westman

    user agreement

    Hi all, No PHP or cookies today just text. I would like to update my Terms of Use / User Agreement - legal page. I am terrible with page content like this and would like to use a good free template. Where do I go for this?
  6. westman

    array in mysqli query

    the output of $limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows; echo "<br /> limit: $limit <br />"; is... limit: LIMIT 190,10
  7. westman

    array in mysqli query

    thank you for the $row info. it tried... $limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows; but got the following error
  8. westman

    array in mysqli query

    works well. thank you. last one. How do I get a variable out the while loop and how do I close the DB connection? Also, is it possible for $limit = 5; to be $limit = "34,5"; as it is a pagination script. PDO is new to me.
  9. westman

    array in mysqli query

    using.... echo $result; my output is 1
  10. westman

    array in mysqli query

    Thank you for your support. I really appropriate it. I am having a problem with this line... while($row = $result->fetch(PDO::FETCH_ASSOC)) {
  11. westman

    array in mysqli query

    $seach = ''; foreach ($uniqueValueArray_id as $key => $value) { $seach .= 'id='.$value; $seach .= ' OR '; } $seach = rtrim($seach,' OR '); echo $seach; $sql = "SELECT id, text, date, FROM text WHERE $seach ORDER BY id DESC $limit"; $query = mysqli_query($conn, $sql); I am getting closer but I do have a problem with the query still. Any help?
  12. westman

    array in mysqli query

    Is it even possible to run an array through a query?
  13. westman

    cookie coding

    Thank you for the answer to my question. Most of what you were discussing I did not follow but thanks.
  14. westman

    cookie coding

    Hi all, I am coding cookies for the first time and here is what I have. setcookie("username", $old_cookie, "1", "/", "", "", TRUE); setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE); Is this the right way of resetting the value of one cookie? ps. I did read a lot on http://php.net/manual/en/function.setcookie.php but it is not clear.
  15. westman

    cookie coding

    In my last topic i opened It was advised to have a new cookie and never use the same one. At the moment my code is setting a new cookie with each page view after being logged in. Is this too excessive?
  16. westman

    cookie coding

    Hi Foxy, Thank you very much for your contribution. I was really quite advance for me but I am sure it wasn't lost on others. In the end I added one more line of code to fix the problem - It probably didn't fix the problem but no errors are show to the page and the cookie gets killed. if (isset($_GET['active'])) { $active = $_GET['active']; if ($active == "logout"){ if(isset($_COOKIE["username"])){ setcookie("username", '', strtotime( '-5 days' ), '/'); } session_destroy(); echo "<script>setTimeout(\"location.replace('http://mysite.com')\",1000)</script>"; exit(); } } as you can see a just added "exit();"
  17. westman

    cookie coding

    Okay I got the biggest puzzle since early man. here is my code.. if (isset($_GET['active'])) { $active = $_GET['active']; if ($active == "logout"){ if(isset($_COOKIE["username"])){ setcookie("username", '', strtotime( '-5 days' ), '/'); } session_destroy(); // This code removes the cookie no problem. However it shows the header error echo "<script>setTimeout(\"location.replace('http://mysite.com')\",1000)</script>"; // this code does not show the header error but need to run the url (mysite/?active=logout) twice to kill the cookie (session destroy works just fine) header("location: http://www.mysite.com"); } } What do I do here?
  18. westman

    cookie coding

    I put the setcookie on the http://mysite.com?p=dashboard page and it works just fine. Thank you everyone for your help. I am sure more questions shall come later 😉
  19. westman

    cookie coding

    I am using... echo "<script>setTimeout(\"location.replace('http://mysite.com?p=dashboard')\",1000)</script>"; at the bottom of my login script. What code can I use where a cookie will be set and I can move my user to a different page? Just testing this code and its not the issue.
  20. westman

    cookie coding

    back to the same problem. It works fine on a blank document but when I put the setcookie code in with my login script the cookie does not set and I get the error about headers again.
  21. westman

    cookie coding

    OMG thank you so much it is working. Polly got a cookie. I put the set cookie at the top of the page and not in the body.
  22. westman

    cookie coding

    I am trying so hard to understand, I am. If someone could provide code of a working example that would be grate to understand from there. I now have this code on one page of my site... setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE); and this code on a different page... if(isset($_COOKIE['username'])){ echo "1"; }else{ echo "0"; } my output is 0 every time. I am not successful at setting my first cookie
  23. westman

    cookie coding

    I have played around with it some more but still get an error when only the line of code to set the cookie is there. Also the line of code "echo" never works for me. What am I doing wrong?
  24. westman

    cookie coding

    Error update. Using this code... $new_cookie = "123456789abcdefg"; setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE); echo $_COOKIE["username"]; echo "<br />"; print_r($_COOKIE); the output is still an error.
  25. westman

    cookie coding

    I have a problem creating my first cookie. I keep getting this error message and when I use... echo $_COOKIE["username"]; I get nothing on the screen.
×