Jump to content

Don E

Members
  • Posts

    996
  • Joined

  • Last visited

Everything posted by Don E

  1. If the second instance of $dateExpiry/"2025-02-26" is being evaluated in the if condition, it's going to go into the else clause because $dateNow is not greater than "2025-02-26". Is that in a while loop? If so, then when the while loop is done, $objectAdvertSpace->expired is going to equal to "0" because the 'if' condition is going to evaluate the last $row["expiry_date"] in the while loop, which if it's "2025-02-26", $objectAdvertSpace->expired is going to be set to "0".
  2. Hey @Chikwado Try wrapping your JavaScript code in a window load event function. For example: window.addEventListener('load', function(){ var photo = ["image/image1.jpg","image/image2.jpg","image/image3.jpg"]; var i = Math.floor(photo.length*Math.random()); document.getElementById("show").src = photo[i]; });
  3. The while loops keeps running because the condition is always TRUE. Try: $pos = StrFind($strText, "'"); //this is position 4 while($pos) //$pos starts as 4 { $strText = StrReplace($strText, "'", "#"); echo "@@@@@@@@@@@@@@@@@@@@<br>"; echo $strText."<br>"; echo "@@@@@@@@@@@@@@@@@@@@<br>"; $pos--; //this decrements $pos in each loop until it becomes zero which is FALSE and the loop should stop. }
  4. To achieve your initial goal, try this: substr_replace("Greg's Native Landscapes","XXXX",4, 1); 4 represents the position as defined in your $n1 variable, and 1 represents the 'length' of characters to replace, which in this instance only 1, the apostrophe.
  5. Don E

    Var vs. Let

    Hello, long time no post, but always reading the forums. I was wondering opinions on what is the good standard/practice or recommendation when it comes to using var or let when declaring variables? I know there are instances when to use let and/or var as shown here for example: https://www.w3schools.com/js/js_let.asp but when browsing around looking at JavaScript code these days, I'm noticing more code with let instead of var even if it's a simple example with a few or so lines of code. I know both var and let have their place when declaring variables, but generally, what would be more of a good standard/practice-recommendation? Thanks.
  6. Hello JSG, Actually it never moves outside the parent element. The issue is when moving the the draggable box really fast, say for example from left to the right edge, the draggable box is suppose to line up directly to the right edge but instead stops a certain amount or so pixels from the right edge thus not lining up directly to right edge. The same happens for the bottom as well. All works well though when moving the mouse slow. For the left and top edges, it works fine regardless of how fast I move the mouse. With the jQuery draggable though, you can move the element as fast as you want toward the edges and it stops/lines up directly.
  7. Hello members, I am trying to make a draggable div element that is similar to the jQuery draggable where you can contain the draggable element inside the parent container. I would like to implement this on one of my pages instead of using the jQuery draggable and also as a learning experience. The following is what I have so far. Everything works as intended but when moving the mouse too fast, it skips mouse coordinates thus not allowing the draggable box to get directly to the edges of the parent container, if that's where the user moves the box to. If move the mouse slow, it does. For example, if you move the box pretty fast to the right edge, it will stop little bit before the right edge. If you move slow, it will line up directly to the edge. Basically works like this: When the user 'mousedown' on the draggable box, it gets the x and y coordinates, then calculate the end coordinates where the box will not move if met. Perhaps I'm missing something or not doing something correctly. Any help is greatly appreciated! Thank you. <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Draggable</title> <style> #parentCont{ background-color: lightgrey; width: 800px; height: 800px; position: relative; border: 2px black solid; } #box{ background-color: lightblue; width: 200px; height: 200px; position: absolute; top: 0; left: 0; cursor: move; } </style> <script> var startX = 0; var startY = 0; var endX = 0; var endY = 0; var endLeftMouse = 0; var endTopMouse = 0; var endRightMouse = 0; var endBottomMouse = 0; var box; var imageCont; window.onload = function() { box = document.getElementById("box"); parentCont = document.getElementById('parentCont'); box.addEventListener('mousedown', function(){ startX = event.clientX; startY = event.clientY; endLeftMouse = parseInt(Math.abs(box.offsetLeft - startX)); //left endTopMouse = parseInt(Math.abs(box.offsetTop - startY)); // top var rightDistBox = (parentCont.clientWidth - box.offsetLeft) - box.offsetWidth; var rightDistXcoor = parentCont.clientWidth - startX; var diffRight = Math.abs(rightDistBox - rightDistXcoor); endRightMouse = parseInt(parentCont.clientWidth - diffRight); //right var heightDistBox = (parentCont.clientHeight - box.offsetTop) - box.offsetHeight; var heightDistYcoor = parentCont.clientHeight - startY; var diffBott = Math.abs(heightDistBox - heightDistYcoor); endBottomMouse = parseInt(parentCont.clientHeight - diffBott); //bottom parentCont.addEventListener('mousemove', moveBox); parentCont.addEventListener("mouseup", stopMove); document.addEventListener("mouseup", stopMove); }); } function moveBox() { if(event.clientX >= endLeftMouse && event.clientY >= endTopMouse && event.clientX <= endRightMouse && event.clientY <= endBottomMouse) { //moves box if no endMouse is met; boundary box.style.left = `${endX + (event.clientX - startX)}px`; box.style.top = `${endY + (event.clientY - startY)}px`; } else if(event.clientX <= endLeftMouse && event.clientY >= endTopMouse && event.clientY <= endBottomMouse){ //if box is at left edge box.style.left = 0 + "px" ; box.style.top = endY + (event.clientY - startY) + "px" } else if(event.clientY <= endTopMouse && event.clientX >= endLeftMouse && event.clientX <= endRightMouse) { //if box is at top edge box.style.top = 0 + "px" ; box.style.left = endX + (event.clientX - startX) + "px"; } else if(event.clientX >= endRightMouse && event.clientY >= endTopMouse && event.clientY <= endBottomMouse) { //if box is at right edge box.style.right = 0 + "px" ; box.style.top = endY + (event.clientY - startY) + "px"; } else if(event.clientY >= endBottomMouse && event.clientX >= endLeftMouse && event.clientX <= endRightMouse) { //if box is at bottom edge box.style.bottom = 0 + "px" ; box.style.left = endX + (event.clientX - startX) + "px"; } } function stopMove() { parentCont.removeEventListener("mousemove", moveBox); endX = parseInt(box.offsetLeft); endY = parseInt(box.offsetTop); } </script> </head> <body> <div id="parentCont"> <div id="box"></div> </div> </body> </html>
  8. Looks like you're missing the opening double quote for type="text". Your browser developer tools is very useful for these situations or any situation. 😉
  9. The SMTP error means you're trying to send mail using the Outlook SMTP server because you have sendmail_from in php.ini set to your email address which is an Outlook email address and you haven't set up the authentication to do so with the Outlook SMTP server. What you can try is to send the mail locally from your server but if your server doesn't have an email server, then you may want to try something like PHPMailer. See this link for it provides how to do send email with PHPMailer with Outlook: https://subinsb.com/send-mails-via-smtp-server-gmail-outlook-php/
  10. Php mail() function first parameter is a string which is the "to" address. You have the $formproc object there instead. Example: mail($to, $subject, $message); // 'me@mail.com', 'this is subject', 'this is a message' Each parameter for the mail function is string. The fourth parameter would be headers which is optional but good to add. See: http://php.net/manual/en/function.mail.php
  11. Hey iwato, are you sure your column names are exactly like in your query? Also something to try, probably makes no difference but since you're calling get_result after execute, instead try to see if you have any num_rows with $mysqli_result->num_rows (get_result should return a result set on successful query) instead of $mysqli_stmt->num_rows.
  12. In the function construct, one of the parameters is the super global $_GET. After doing some testing just to be certain, you cannot re-assign values to it. This is the error I got while testing: Fatal error: Cannot re-assign auto-global variable _GET in /Applications/MAMP/htdocs/testing/classTest.php on line 12 Did you see this error? I noticed the super global $_GET earlier in the construct but dismissed/overlooked it.
  13. Have you tried printing the stmt and result objects after the match attempt to see for errors? Also not sure if this may be the issue but I don't think you need to call the first line below because when calling 'prepare' it returns a stmt object for you. $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql_select); So instead try: $mysqli_stmt = $this->mysqli_obj->prepare($sql_select); Also noticed: $match = mysqli_num_rows($mysqli_result); Looks like calling procedural function calling attempt? Instead for number of rows, try: $mysqli_stmt->num_rows Use in the if condition instead of $match > 0. Also noticed and just to note, when calling a function from another function within the same object, use $this->update_record(); instead of just update_record(); Good luck! I'm sure some of the others will be here to assist as well!
  14. I agree. It's not too awful. Good luck with everything. 👍🏼
  15. What you can do to give you the result you're looking for is converting your videos to gifs. Gifs automatically play on iOS devices. Here is one of your videos converted to a gif using video gif maker at https://editthis.net/videogif The downside to this though is depending on the length(duration) and size(width and height) of gif, the file size can be big resulting in the gifs taking some time to load on the webpage.
  16. I believe this was a change with iOS. I've noticed this for awhile now. (years)
  17. Function select is not defined as a static method. PHP gave the error because select is not a static method and when trying to access a non static method, you need to create an object for it, for that class to access that method. When not, like in your code, you're using $this as a non object resulting in the fatal error. getInstance is a static function thus why it worked.
  18. Well, I was just offering a quick solution to try. I would comment out all the rewrite conditions and rules that are not of concern at first and work only with the non www to www. Although the poster mentioned re-ordering the rules and still not working, commenting out the other rules for testing the condition and rule you want is helpful in isolating incase any of the other conditions and rules are conflicting somehow. I see that the poster does not have ^ and $ for the RewriteRule for (.*). This may or may not be the the issue but from my understanding it's good practice to have in the rewrite rule the beginning(^) and end indicators($).
  19. Try: RewriteCond %{HTTP_HOST} ^newsite.co.uk [NC] RewriteRule ^(.*)$ http://www.newsite.co.uk/$1 [L,R=301,NC]
  20. Sounds like URL rewriting is taking place. In most cases this is taking place in the .htaccess file. If so, you may want to comment out the lines in the .htaccess file that is taking place or remove it all together but be cautious to not remove anything that can cause an internal error for your site; making your site inaccessible.
  21. Yes that's what I meant. Instead of SET $colName = $colName + 1, you can just do: SET opener_Ask = opener_Ask + 1. In this situation you probably don't need to do a prepare statement for that column. Usually/typically, doing prepare statements are when user inputs are being used/supplied for SQL queries but on some occasions it's not necessary. But it's definitely good practice.
  22. Are you saying that the actual file name is stream.php but the URL appears as steam.m3u8 in the browser but would like to see it in the browser as stream.php instead?
  23. Looks like you are trying to set a column name with bind_param. You can just name the column after SET instead of trying to bind_param it with ?. Also if the column name is opener_Ask, why aren't you updating that column row value with "opener_Ask + 1"? Also, Between bind_param and execute, you set the parameters like the following: $stmt->bind_param("ssi", $colName, $colName, $sesID); $colName = $colName; $sesID = $sesID; $stmt->execute(); See https://www.w3schools.com/php/php_mysql_prepared_statements.asp
  24. Check out some of the $_SERVER vars: http://php.net/manual/en/reserved.variables.server.php
×
×
  • Create New...