WoHe

Members
  • Content count

    14
  • Joined

  • Last visited

Community Reputation

2 Neutral

About WoHe

  • Rank
    Newbie

Previous Fields

  • Languages
    HTML, CSS, JavaScript, jQuery, PHP, SQL, Java, Python

Profile Information

  • Gender
    Male
  • Location
    Europe
  1. Oh thanks a lot! I keep making this mistake everywhere...
  2. So the grid view that is explained here does not work in my own document. This is the code I'm using: /*GRID VIEW*/ [class*="col"] { width: 100%; } @media only screen and (min-width: 720px) { .col1 {width: 8,33%;} .col2 {width: 16,67%;} .col3 {width: 25,00%;} .col4 {width: 33,33%;} .col5 {width: 41,67%:} .col6 {width: 50,00%;} .col7 {width: 58,33%;} .col8 {width: 66,67%;} .col9 {width: 75,00%;} .col10 {width: 83,33%;} .col11 {width: 91,67%;} .col12 {width: 100,00%;} } /*LAYOUT*/ * { font-family: sans-serif; border: 0.1px solid black; } body { width: 100vw; height: 100vh; overflow-y: scroll; margin: 0; } div { height: 100px; background-color: red; } <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div class="col3"></div> </body> Does anyone see what's wrong? The div has always a width of 100% in my browser (safari)... Thanks!
  3. So my question is: how can I insert variables into my mysql queries in php? This is my code now, I would like to use the $me and the $friend variables to work in the sql query: function newChat($me, $friend) { global $conn; $sql = "SELECT id FROM chats WHERE (person1 = $me AND person2 = $friend) OR (person1 = $friend AND person2 = $me);"; mysqli_query($conn, $sql) or die('Error querying database.'); echo "check <br />"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { echo $row['id'] . ' - ' . $row['person1'] . ' - ' . $row['person2'] . ' - ' . $row['date'] .'<br />'; } } newChat('John', 'Marie'); Also if I set $sql to "SELECT * FROM chats" it only gives me one row of my two test rowes in my database. (it only gives the second row, and just ignores the first one? --> a screenshot of the database is at the end of this post) Can anyone please help me with this? Thanks already!
  4. I was wondering if there is any way to set unique values to each cookie. I want to use these cookies on my website to see if the visitor has already visited my website once, but without asking any information from them. This way I want to store this unique value in my database each time someone opens my website, and I will be able to see if there have been - for example - 20 different visitors in the past month, or if the same person has visited my website 20 times. All my code is already written and working, I only need a way to set a different unique value to each cookie I set.
  5. Ok, thanks a lot!
  6. So I have rebuild the code piece by piece and I have found the problem. The problem was in this piece of the code: echo "no cookie found <br />"; I don't know why this would cause a problem, but I don't need it anyway for the actual code, it was just to check if my code works (ironically). I'm still learning php so if you could figure out how this causes a problem, could you please explain it to me? Thanks already!
  7. You could maybe try to float:right the image. I'm also new , but I had a similar problem and it worked when I used this float:right.
  8. I had to set the domain to "localhost" to let the code work, I have now also set an expire date. The only remaining problem is that setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); doesn't work in an if-statement (as mentioned earlier), it does work outside and inside of any function, but not inside of the if-else statement... For example: This works: setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); This works: function set($cookiename, $cookievalue) { setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); } set($cookiename, $cookievalue); But this doesn't work: if(!isset($_COOKIE[$cookiename])) { echo "no cookie found <br />"; setcookie($cookiename, $cookievalue, time() + (86400 * 30), "/", "localhost"); }
  9. Your typed "right:0ox" instead of "right:0px", maybe this causes the problem, also I don't think the "right:0px" is necessary, by using the following code it should be on the bottom of the page and take up all the available width: <div style="bottom: 0px; left: 0px; position: absolute; width 100%; background-color:red;"> Status bar <div></div> </div> Also you used "background:red" instead of "background-color:red".
  10. Could you tell me more specific what you want to do? As I see it, you've got in input field with type=text and you want to copy the text from this input field into another element. I should do this with javascript: var text = document.getElementById("[id of the input field]").value; document.getElementById("[id of the other element]").innerHTML = text;
  11. And what do I need to set the $expires parameter if I don't want it to expire? Also, I don't think localhost is be the issue, because in all the other cases it does work, except for the case where it is set in the if-statement... PS: I've set the expire parameter to time() + (86400 * 30) and it still doesn't work...
  12. That is what I thought too, but I keep refreshing the page with this exact code and it keeps telling "no cookie found not able to set cookie".
  13. Thanks, but it also doesn't work when I use it in an if-statement, like this: $cookiename = "test"; $cookievalue = "test"; if(!isset($_COOKIE[$cookiename])) { echo "no cookie found <br />"; setcookie($cookiename, $cookievalue, false, "/", "localhost"); if(!isset($_COOKIE[$cookiename])) { echo "not able to set cookie <br />"; } else { echo "cookie '" . $_COOKIE[$cookiename] . "' is set correctly <br />"; } } else { $cookievalue = $_COOKIE[$cookiename]; echo "cookie found: " . $cookievalue . "<br />"; } (this is btw my whole code for checking if there is a cookie and setting it if none is found)
  14. I am trying to set a cookie when there is no cookie from my website found on the user's PC, but the following line of code doesn't work inside a function: $cookiename = "test"; $cookievalue = "tests"; setcookie($cookiename, $cookievalue, false, "/", "localhost"); It does work however if it is placed outside of the function. For exampe, the code above works, but the next code doesn't: $cookiename = "test"; $cookievalue = "tests"; function addCookie() { setcookie($cookiename, $cookievalue, false, "/", "localhost"); } addCookie();