Jump to content

PNewCode

Members
  • Posts

    315
  • Joined

  • Last visited

Everything posted by PNewCode

  1. @kicken WOW I can't believe I didn't make the DBconnection hahaha. Okay, so with your answer and adding the DB connection it works. Thanky you so much! // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE nametable SET reqid='75' WHERE name='MetalHead'"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close();
  2. This looks like what I need. So below is what I made, though all of the colums with the name JOE still shows zero. I'll add a screen shot Note: Joe was just an example. In the screen shot below, I'm attempting to update all that has the name "MetalHead" with "75" <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $servername = "removed for posting"; $username = "removed for posting"; $password = "removed for posting"; $dbname = "removed for posting"; $sql = "SELECT * FROM nametable"; $sql= "UPDATE nametable SET reqid= '75' WHERE name='MetalHead' "; ?> The screen shot of the DB EDIT: No errors are showing on the screen
  3. Hello. It's been a while since I've been here and I hope everyone is doing well. My task that I'm taking on is adding a value to all entries based on username. I added the new column and need to add that in for a different project. But I haven't started the other one yet because I need to get this done first. I tried to google this and I keep getting results that aren't what I need (IE How to insert multiple rows, or how to replace values in phpmyadmin, etc) To be more specific, lets say user "joe" has 200 entries. Joe is a user that has a reqid that is the number 75 Now I've added the column "reqid" I need to add the number 75 in the column reqid, to all the entries made be Joe The column is INT(255) Note: Each user has a different name, and I already have a working way to add the reqid to the database from this point on. So what I need to do is edit all the past entries before today with their reqid's I don't have anything that I have tried because I'm running in circles on what to do. If anyone has an example script that will get me in the right direction, or a link where I can see how this is done, I would appreciate it so very much. Note 2: Ultimately I would like to make a form where I can just search a name and add that in for all of that users entries, but if this can be done in phpmyadmin in a batch update that will work too (the search doesn't seem to allow to replace just one user to change (example 0 to 75)
  4. @mac_gyver it takes over the whole screen with the "out of memory click here to refresh" and if you refresh then it loads it all again just fine, but the viewers are aggravated. No other error is showing on screen, log, or console. Based on youre reply I'm thinking it's probably from the ajax call loading the page every 1.5 seconds
  5. Hello everyone. I have a chat that I made. The problem is that it crashes every 10-50 min (depending on how many people are in there). I know having it refresh with ajax every second isn't the smartest way but could that be the reason? The error is "out of memory". Everything that I'm reading says it's a browser thing but every single viewer is getting the exact same thing on all browsers (sometimes worded a little different on some browsers) Chrome, Firefox, Edge, Android default, and Safari all do this. I don't know a thing about websockets, but it looks like this could be preventing that. Is that true? I cringe at having to learn all that stuff with Node.js and stuff it looks like this will require. So I'm hoping maybe there's a diffent solution Note: I didn't include any code here because it's a general question really. And my chat is made up of 4 different files for customization and stuff. It is using php mysql database and ajax every 1.5 second to load the chat to prevent lag from entering a post and appearing in the chat window. All advice is appreciated. Note 2: If you're wondering "Why are you using a database and ajax" the answer is, because thats at the extent that I've learned so far. Edit: I forgot to add that there are no errors showing or warnings in the console or logs, not even suggestions
  6. I found this handy litle gem after a 2 hr nap and 4 cups of coffee in case anyone else happens to find it useful. Added this then made an outside containing div. Works perfectly! <script> var launchFullScreen = function(el) { // alert('launching'); // var el = $el[0]; if (el.requestFullscreen) { console.log('requestFullscreen'); el.requestFullscreen(); } else if (el.mozRequestFullScreen) { console.log('mozRequestFullScreen'); el.mozRequestFullScreen(); } else if (el.webkitRequestFullscreen) { console.log('webkitRequestFullscreen'); el.webkitRequestFullscreen(); } else if (el.msRequestFullscreen) { console.log('msRequestFullscreen'); el.msRequestFullscreen(); } else { console.log('no full screen'); } }; var exitFullscreen = function() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } }; // window.addEventListener('orientationchange', function() { window.screen.orientation.onchange = function() { console.log(window.screen.orientation); if (this.type.startsWith("landscape")) { // document.querySelector("#containvid").webkitRequestFullscreen(); launchFullScreen(document.querySelector("#containvid")); } else { // document.webkitExitFullscreen(); exitFullscreen(); } }; var containvid = document.querySelector("#containvid"); var video = document.querySelector("video"); var controls = document.querySelector("#controls"); var play = document.querySelector("#play"); var fullscreen = document.querySelector("#fullscreen"); play.onclick = function() { if (video.paused) { video.play(); play.innerHTML = "pause"; } else { video.pause(); play.innerHTML = "play_arrow"; } }; fullscreen.onclick = function() { if (document.webkitFullscreenElement != containvid) { containvid.webkitRequestFullScreen(); window.screen.orientation.lock("landscape"); fullscreen.innerHTML = "fullscreen_exit"; } else { document.webkitExitFullscreen(); fullscreen.innerHTML = "fullscreen"; } }; // document.onwebkitfullscreenchange = function() { // if (document.webkitFullscreenElement != containvid) { // fullscreen.innerHTML = "fullscreen"; // } // }; </script> <div id="containvid"> <div id="twitch-embed"></div> </div>
  7. Hello. What I have below is a twitch embed. When on mobile and the screen is rotated, the video does cover the area inside the browser window but it doesn't cover the entire screen (like it does if you were watching a stream on the twitch website) Is there a way to add or alter what I have to make it cover the entire screen when rotated and not just inside the browser window? <style> #twitch-embed { height: 0; position: relative; top: 0; overflow: hidden; padding: 0 0 56.25%; width: 100%; border-radius: 8px; } #twitch-embed iframe { position: absolute; bottom: 0; height: 100%; width: 100%; z-index: 35; } </style> <!-- Add a placeholder for the Twitch embed --> <div id="twitch-embed"></div> <!-- Load the Twitch embed script --> <script src="https://player.twitch.tv/js/embed/v1.js"></script> <!-- Create a Twitch.Player object. This will render within the placeholder div --> <script type="text/javascript"> new Twitch.Player("twitch-embed", { width: "100%", height: "100vh", channel: "channelname" }); </script>
  8. @kicken I APOLOGIZE!!! I'm having a total DUH moment. Your suggestion is spot on! The problem was that I was reupling the wrong file, and thats why I didn't see a change. THAT is embarrassing to say the least haha. Thank you for the help and also for explaining it so I can understand. Huge help. THANK YOU!
  9. I'm not sure what I'm missing then. If I put in echo $viewspec_pref; I get the output of no or blank (nothing written), depending on what the value is in the db so I'm not sure why that is being ignored.
  10. @kicken Thank you so much for that. This explains a lot, however isn't working. The !== false is giving me the same result as == true, but I understand now the need to put it as a strict statement tp make it correct. The problem though, is that even with the following, the condition of "no" is being ignored. If I have no or just empty then it has the same result. Any thoughts? The first part should only work if the viewspec_pref has "no" as the value
  11. @ginerjm To help you move on from that... here's the proof THESE ARE SCREEN SHOTS OF THE WEBSITE RIGHT NOW!!! This is how it looks with AND WITHOUT using if (strpos($row["message"], 'And Click') == true) { Now can we PLEASE move on from the part that is not what I even made this post about please??? You keep dwelling on something that isn't an issue. It's like I'm asking how to fix a flat tire, and you ask me why I don't have a spare!
  12. @ginerjm sorry that you can't move past it. I don't know how to convince you that it works since I am literally looking at the web page right now and it is hiding the info as needed. You should forget about that because it's working as it should. THAT is NOT the problem. The problem is that I need this to look at TWO if conditions (like I said) 1: that it hides the message if it contains the words "And Click" (THIS WORKS) 2: That it only hides this if the user has a value of "no" in the column "$viewspec_pref" (I CANNOT GET THIS PART ADDED... WHICH IS THE ENTIRE POINT OF THIS POST!) See... Number 1 and number 2.... Two if statements! Thats what the heck that means!
  13. @ginerjm Oh I see it's just how it looks when adding a code. You didni't change anything from mine. Still, this isn't the issue. It's working. I know this tends to be a thing where I have to keep saying that, but since it's not the reason for this post at all, can we just move on from weather it works or not? Because trust me, it does. It's on my webpage, published to the website, and it's working. The problem...... is that I need it to ALSO look for $viewspec_pref == "no" ... as I explained I'm sorry but I don't want to focus on a part of this post that I'm not even asking to change or get help for. If it's not broken then why change it? That part that you explained is working. So can I get some help with what this post is about please
  14. @ginerjm Thank you. I added the spaces as you suggested. I'm getting the same result. What I need to do with this is make it so it looks for that and also if the $viewspec_pref == "no". I need both of these to be as so for it to work right, otherwise it's all hidden regardless if the user has yes or no entered
  15. Hello My new task is trying to have 2 different things to look at to echo a phrase. One is to look if the user has a column set to no, and the other is if it contains a phrase. So for example, if BOB has viewspec_pref set to NO, then he will not see any posts that contain the words "And Click" I have tested that all of it is connecting to the database by echo'ing out each column. This line works to hide the message if it says 'And Click' (this is inside the column $message) ////// works for hiding from every user ////// if (strpos($row["message"], 'And Click') == true) { } else { echo $message; } What I need to do is have it for more than just the word Click, AND... also only if the user has $viewspec_pref set to "no" This is what I tried and I get no result at all Also, for some reason I am not seeing any errors (yes I have that turned on and there is nothing in the log.. and the consol is a bit confusing to me) ////// I Tried ////// if (strpos($row["message"], 'And Click') == true) && if ($viewspec_pref == "no") { } else { echo $message; } ////// Also Tried ////// if (strpos($row["message"], 'And Click') == true) && ($viewspec_pref == "no") { } else { echo $message; } ////// AND Also Tried ////// if (strpos($row["message"], 'And Click') == true) && $viewspec_pref == "no" { } else { echo $message; } ////// AND Also Tried ////// if (strpos($row["message"], 'And Click') == true) && $viewspec_pref == "no"; { } else { echo $message; }
  16. True @gizmola but for anyone that doesn't have admin permissions get redirected to a page that doesn't have the button on it at all. @Barand I got the bloody delete button to work. HOWEVER, after all of that work, I discovered that it doesn't work when the entire page is visible through another ajax script that loads the page to the main page (it's a chat window so I use ajax to keep looking for new entries) SO it looks like that all the work was wasted and I can't go this route at all unless I figure out another way to load the page and have it keep looking for database changes. I'm no where near ready to understand node and websockets and stuff
  17. Yes I'll admit I got this wrong because I just bypassed the ajax page and still doesn't work. I'm baffled. I've made several of these pages and not a single issue. I feel like it's something thats staring me in the face to fix and I can't see what it is. I know you just gave me a hint but I don't know what that means haha. Anywho, I think I'll circle back to that issue once I get this bloody delete thing figured out. Argh
  18. Okay that was put very awesome like lol. I rather liked that. So maybe you can shed some light on that then. Keep in mind, everything works (except still the delete thing, and I would make this a new question but you commented on my other issue that I made a comment of) but it wont accept special characters to insert into the DB. I can't see any errors because this makes it so you don't leave the page post_chat.php <?php session_start(); error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <style> #hideMe { -webkit-animation: cssAnimation 5s forwards; animation: cssAnimation 2s forwards; } @keyframes cssAnimation { 0% {opacity: 5;} 20% {opacity: 4;} 40% {opacity: 3;} 60% {opacity: 2;} 80% {opacity: 1;} 100% {opacity: 0;} } @-webkit-keyframes cssAnimation { 0% {opacity: 5;} 20% {opacity: 4;} 40% {opacity: 3;} 60% {opacity: 2;} 80% {opacity: 1;} 100% {opacity: 0;} } </style> <?php // Start the session if(!isset($_SESSION['id'])){ header("location: login.php"); } ?> <?php $user_id = $_SESSION['id']; ?> <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $localhost = "localhost"; $dbusername = "deleted for posting"; $dbpassword = "deleted for posting"; $dbname = "deleted for posting"; #connection string $conn = mysqli_connect($localhost,$dbusername,$dbpassword,$dbname); if(!$conn){ echo "Database connection error".mysqli_connect_error(); } $sql = "SELECT * FROM users WHERE id = '$user_id'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $user_token = $row["token"]; $fname = $row["fname"]; } } else { echo " "; } $pname = ""; if(!empty($_FILES["file"]["name"])){ $allowed_img = array('gif', 'png', 'jpg', 'jpeg'); $img_ext = $_FILES["file"]["name"]; $ext = pathinfo($img_ext, PATHINFO_EXTENSION); if (!in_array($ext, $allowed_img)) { if (!in_array($ext, $allowed_img)) { echo '<table width="80%" border="0" cellspacing="0" cellpadding="5" align="center"> <tr align="center" valign="middle"> <td> <p><img src="assetimgs/invalid-banner.png" width="530" height="114"></p> <p>&nbsp;</p> </td> </tr> <tr background="assetimgs/fade.png" align="center" valign="middle"> <td> <p><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif"><b><font size="6">Sorry!</font><br> <br> Only <font color="#FF9933">gif</font>, <font color="#FF9933">png</font>, <font color="#FF9933">jpeg</font> and <font color="#FF9933">jpg</font> is allowed to upload<br> <br> No Tokens Have Been Taken<br> </b></font></p> <p><font face="Verdana, Arial, Helvetica, sans-serif"><a href="picshow/pic-form.php"><font color="#9999FF">Click Here To Try Again</font></a></font></p> </td> </tr> </table>'; } die(); } } $mybandid = mysqli_real_escape_string($conn, $_POST['mybandid']); $fname = mysqli_real_escape_string($conn, $_POST['fname']); $table_pref1 = mysqli_real_escape_string($conn, $_POST['table_pref1']); $table_pref2 = mysqli_real_escape_string($conn, $_POST['table_pref2']); $name_pref = mysqli_real_escape_string($conn, $_POST['name_pref']); $text_pref = mysqli_real_escape_string($conn, $_POST['text_pref']); $back_pref = mysqli_real_escape_string($conn, $_POST['back_pref']); $message = mysqli_real_escape_string($conn, $_POST['message']); if(mysqli_query($conn,$sql)){ echo " "; } else{ echo "Error"; } ?> <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $connection = mysqli_connect('connection stuff deleted for posting'); extract($_POST); $data = ''; foreach($_POST as $k => $v) { if(empty($data)) { $data .= "$k ='$v'"; } else { $data .= ", $k='$v'"; } } $sql = "INSERT INTO livechat_chat set $data"; $results = mysqli_query($connection, $sql); if($results) { echo "<div id='hideMe'>POSTED!</div>"; } else { echo "<div id='hideMe'>Changes failed, Please Try Again</div>"; } And the form.php <form action="#" method="post" id="manage_post_chat" enctype="multipart/form-data" autocomplete="off" accept-charset="utf-8"> <font face="Verdana, Arial, Helvetica, sans-serif"><label></label><label><font color="#FF3333"> </font></label> <font face="Verdana, Arial, Helvetica, sans-serif"><font face="Verdana, Arial, Helvetica, sans-serif"> <span class="image-upload"> <label for="file-input"> </label></span></font></font></font> <font face="Verdana, Arial, Helvetica, sans-serif"> <input type="hidden" name="badge" style="font-size:18pt;" value="<?php echo $badge; ?>" required /> <input type="hidden" name="mybandid" style="font-size:18pt;" value="<?php echo $id; ?>" required /> <input type="hidden" name="fname" style="font-size:18pt;" value="<?php echo $fname; ?>" required /> <input type="hidden" name="table_pref1" value="<?php echo $table_pref1; ?>" required /> <input type="hidden" name="table_pref2" value="<?php echo $table_pref2; ?>" required /> <input type="hidden" name="name_pref" value="<?php echo $name_pref; ?>" required /> <input type="hidden" name="text_pref" value="<?php echo $text_pref; ?>" required /> <input type="hidden" name="back_pref" value="<?php echo $back_pref; ?>" required /> <input type="hidden" name="back_texture" value="<?php echo $back_texture; ?>" required /> </font> <table width="100%" border="1" cellspacing="0" cellpadding="2" align="center" class="table-roundmenue8 fixed" bgcolor="#000000" background="brushed01.jpg"> <tr align="center" valign="middle"> <td colspan="4" height="44"> <table width="98%" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="1%" align="center" valign="middle" class="table-roundmenue-admin" height="4"><span class="image-upload"><label for="file-input"></label> <font face="Verdana, Arial, Helvetica, sans-serif"><button type="button" class="button-emoji second-btn uk-button uk-button-primary pointer"></button><br> </font> </span> </td> <td width="92%" valign="middle" align="center" height="4"> <input type="text" name="message" size="30" style="font-size:16pt;" class="table-roundmenue-saysomething two uk-textarea uk-margin" placeholder="Say Something" autocomplete="off"> </td> <td width="7%" align="center" valign="middle" height="4"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="center" valign="middle"> <td> <div class="form-group"> <input type="submit" class="button btn btn-success" name="submit" value=""> </div> </td> </tr> </table> </td> </tr> </table> <table width="100%" border="0" cellspacing="10" cellpadding="10" align="right"> <tr> <td width="8%" background="fade.png" class="table-roundmenue-admin" height="23" align="center" valign="middle"> <img src="btn/puppy.png" style="font-size:30px;cursor:pointer" onClick="openNav30()"><br> <span class="image-upload"><img src="btn/pic3.png" style="font-size:30px;cursor:pointer" onClick="openNav8()" class="button4 image-upload"></span> </td> <td width="8%" background="fade.png" class="table-roundmenue-admin" height="23" align="center" valign="middle"><img src="btn/shot.png" style="font-size:30px;cursor:pointer" onClick="openNav26()"><br> <img src="btn/stickers2.png" style="font-size:30px;cursor:pointer" onClick="openNav29()"> </td> <td width="8%" background="fade.png" class="table-roundmenue-admin" height="23" align="center" valign="middle"><img src="btn/requests.png" style="font-size:30px;cursor:pointer" onClick="openNav3()"><br> <img src="btn/requests-free.png" style="font-size:30px;cursor:pointer" onClick="openNav4()"> </td> <td width="5%"background="fade.png" class="table-roundmenue-admin" height="23" align="center" valign="middle"><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><?php include 'level-tokens.php';?> </b></font></td> <td width="1%" align="right" valign="middle" background="fade.png" class="table-roundmenue-admin" height="23"> <div id="tableHolder"></div> </td> <td width="78%" align="right" valign="middle" background="fade.png" class="table-roundmenue-admin" height="23"><span style="font-size:30px;cursor:pointer" onClick="openNav()"><img src="btn/settings.png"></span><br> <div id="admindiv"></div> </td> </tr> </table> </td> </tr> </table> </form> <script src="action-chatform.js"></script> And the JS (action-chatform.js) $(document).ready(function() { $('#manage_post_chat').submit(function(e) { e.preventDefault() $.ajax({ url: 'post_chat.php', data: $(this).serialize(), method: 'POST', success: function(resp) { $('#error_msg_chat').html(resp); $("#manage_post_chat").trigger("reset"); } }) }) })
  19. I'm beginning to think that ajax isn't the way to go. I like how the original way can send to the database without leaving the page, but I just discovered that you can't send with special characters like an apostrophe like you can if you send the form directly to the php file
  20. @Barand yes even with his post because of the following It wasn't I thought that I am? Yes, I have it so only people with admin permissions can even see the delete button at all. This doesn't help with passing the id though I just don't even understand what this means haha. Sadly, this is like if I were to tell someone that has never held a guitar pic, how to play like Seve Vai... @mac_gyver is Steve Vai, I'm the guy holding the pic I don't know what that means Here is what I had, and what I"m trying to do... condensed in a bad drawing because the entirety of the pages is way to much to post in here for one question. It would just be a headache to scroll through
  21. @mac_gyver no it wasn't part of an echo. It was used to pass a form from a different page that didn't require sending an id with it. So now I'm trying to use it for that purpose of using an id. I just don't seem to be able to figure out how. It works fine if there was no php?id= part of anything. So on the original page, there is a loop that lists the contents from a database. The link that works if it was used to send to the delete-post.php page is, for one id example, delete-post-2.php?id=2012 (or whatever the id ends up being) So I decided I wanted the delete to work without leaving the page like what happens when posting something to the database. Thats where I'm stuck because I can't figure out how to pass the id to the delete page with the ajax script
  22. For anyone else that may come to see this, here is the solution. Credit goes to a friend that I just got lucky enough to rarely see online if (!empty($row["emotes2"])) { $selectedImages = $row["emotes2"]; // This should be a string like "3.png", "4.png", "5.png" $imageArray = explode(", ", $selectedImages); // Convert the string to an array foreach ($imageArray as $emotes2) { echo "<img src='img-picker/images/" . trim($emotes2, ' "') . "' width='35'/>"; } } else { echo ''; }
  23. @maxxd Thank you. I honestly have no idea why I got that 403 before because I did a lot of messing around with the codes since the post but now I'm still getting a 403 for the image folder, which makes sense because it's for viewing only images from the folder are being displayed correctly on the page. Still I get the id error. The original post's code for sending the delete is still the same The error in the console for the id error
  24. @maxxd I'm sorry. I didn't show the database because it's connecting fine so I thought it would be overkill in the post. I'll show it below. Yes, the code is working as expected for as it is, like I said I know why it's doing what it's doing. But I'm trying to alter it so it only displays what is entered in the database. In the column called "emotes2", there is an entry I'm trying to make the code I have display only the two image file names (as images) instead of all 8 images All 8 are "1.png", "2.png", "3.png", "4.png", "5.png", "6.png", "7.png", "8.png" In the database entry there is "1.png", "6.png" So I'm trying to echo only "1.png", "6.png" images on the page instead of all 8 And if the entry said 2.png, 3.png, 7.png then only show those 3 file names as images. (it will change as different users select various different ones for different posts) Here is the database info (note that I'm using * because there are 20+ other columns that the rest of the page is using the different columns for in various other scripts. The page entirety is very long) this issue is only for the column emotes2 $hostname_l = "localhost"; $username_l = "deleted for posting"; $password_l = "deleted for posting"; $dbname_l = "deleted for posting"; $conn_l = mysqli_connect($hostname_l, $username_l, $password_l, $dbname_l); if(!$conn_l){ echo "Database connection error".mysqli_connect_error(); } $user_id = $_SESSION['id']; $sql_l = "SELECT * FROM users WHERE id = '$user_id'";
×
×
  • 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.