PNewCode
Members-
Posts
331 -
Joined
-
Last visited
Everything posted by PNewCode
-
how to updat 2 tables in one database within one form?
PNewCode replied to PNewCode's topic in PHP Coding Help
Because I want to try more before I ask for more help. I was just letting you know that what you replied sent me on the path to knowing what to do so thank you. I'll update if I get a solution or hit a brick wall trying -
how to updat 2 tables in one database within one form?
PNewCode replied to PNewCode's topic in PHP Coding Help
@ginerjm Thank you. That helped a lot. I'm at number 60 in fails at adding a 2nd query and making it work, but now I know that it's what I have to do to make that work. -
Hello I have a working form that sends info to another page and enters it in the database. What I am trying to do is add $sql2 ="UPDATE bandstage SET jkredeem ='used' WHERE mybandid = $user_id"; to the bit below I'm not including the form or the rest of the database connection because all of that is working with no issues and I think it will just clutter up the question. So the object is to keep what is working below, and also update the column "jkredeem" from the table "bandstage" to "used" (which "bandstage" is a different table in the same database) If there's any question why I wrote it the way I did below, the answer is this is how I know to do it while I'm still learning. Thats the only reason I can offer :) $sql = "INSERT into redeemjk (mybandid,audio,title,bandname,contactname,email) VALUES('$mybandid','$song','$title','$bandname','$contactname','$email')"; if(mysqli_query($conn,$sql)){ echo " "; } else{ echo "Error"; }
-
@kicken please forgive the crude drawing. I hoped that this will make it more clear because I am aware that I am not gifted in explaining my end goal The biggest thing though, is that all would be right as rain and wonderful if I could just make the redirect work while it's in an iframe. I don't know what is making it stop. But if I have that page on the side in a different tab, while the game is being played, then everything works. I just can't get it to work while it's in the same page in an iframe. PS... it's okay to laugh at my people drawing. I am too haha
-
@kicken So when the user enters in the 10th entry, then tries to go back to do an 11th try, they can't because the redirect goes to a page that shuts off the game with some other code. This works fine outside an iframe on a page of it's own. But when inside an iframe then it just freezes up to a blank page (no errors, not logged errors that I can find either). It's like it's saying "ummmm..... what do you want me to do now" but only when in an iframe
-
@ginerjm forms are on various different pages. There's a bunch of little games. Trivia, bingo, etc. When they enter their guess for whatever game they play, the entry goes into the database. This is just one of many. Some of these will redirect after 20 entries, some after 5, depends on the game. I just chose this one because it's a nice round number. For the sake of answering your question though... This is game "A". When the person opens GAME A, they get 10 trivia questions. One at a time these get entered because each question is on a timer. So at the end of GAME A, 10 entries are in the database. And this is working just fine. If they try to go back to GAME A, they can't because all 10 entries are full, and they have to start all over again (this is an entirely different set of pages and functions to start over. So it doesn't matter here) And then after they reset, they can enter 10 more answers. SO... this page sits in an iframe so that it is open and active on the side. Untill all ten entries are used, it just says "TADA" (I plan to change that to something more fun) And then, when all 10 are done, they get redirected to free-off3.php, which sets the game to close. But anyways... all is working. The problem isn't where or how everything is getting entered. The problem is WHEN it hits that 10th one then instead of redirecting, the page freezes like a deer in headlights. But only when it's in an iframe
-
@ginerjm Thats exactly it. You got it The point of it is to have a limit on certain entries then get redirected. The redirect lands on a page that clears out those entries AND resets a different database (4 of them actually) to defauly entries. It's a series of games like bingo and stuff. The problem is, I want all of this in an iframe. It works great as a stand-alone page (not in an iframe, in case I'm using the wrong termonology). But having this page inside an iframe then it locks up and freezes when the 10th entry is entered. I saw somewhere that header redirects don't work in iframes but I know thats not true because I have a different page that has one within an iframe. And I tested that theory by changing the redirect to some random text to echo out.
-
Here is my new project. I have everything working wonderfully. I was so happy with it.... Untill... This is to be in an iframe. There's many reasons for that, none of the "why an iframe" are important really. It's just mainly to keep this part of a flow that is also in the same iframe. The problem is, once the database gets to 10 (yes I posted similar to this before but this is stemming off of that) Then it redirects. YAY! that works, unless its in an iframe. I suspected it might be the header redirect so I changed it to just echo some random text, and that didn't matter. It seems to be the 10 entry functioning that I'm doing that puts it at a full stop in the flow of pages. Any thoughts? <?php //// connection stuff here deleted for posting //// // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id FROM nametable"; $result = $conn->query($sql); $resultt = mysqli_query($conn, "select COUNT(id) AS count FROM `nametable` "); if(!$result) { die('Error: ' . mysqli_error($link)); } else { $num_rows = mysqli_fetch_assoc($resultt); // echo it } if ($num_rows['count'] == 10) { header("Location: free-off3.php"); }else{ echo "<font color='#000000'>TADA</font> "; } ?>
-
@Barand only way I can with this one is to try different things till something works since I'm limited. I'm just told the table is "retirees" the column is "birthday" and it is formatted in varchar as day/month/year (01-01-1960) but he didn't tell me the year was reset to current year to just a little bit ago. Thank you for the idea, but what I have works now. If I'm not mistaken, you're idea you just posted would show everyone, but in the order of whos birthday is first to last. He wanted the page to only show those that had the birthday on the day you visit the page. There's animation that has a birthday cake and flickering candles and a song that plays "happy birthday" and in the middle it shows the persons face, then under it their hobbies, and crafts and stuff like that. But only shows this for the people that had a birthday on the day of viewing the site. I fully admit, this was a challenge and a half when I can't see the actual entries and database. I COULD technically run a list of everything but that would be going against the promise I made not to meddle I would be interested in knowing how to alter what I have to show for any year though instead of just the current year, just in case I ever want to use this work for my own website
-
@Barand Thank you for the reply. I didn't know of that fact till just moments ago when I made the reply. He just told me the format example that I put in the post. I promise I wasn't aware of the dates being reset. I don't have permission to look at all of the information as it actually is in the database unfortunately so it made it harder to do. I could only post with the information I was given. Sorry about that.
-
@ginerjm and @Barand So I owe an apology but trust I didn't know. I found this infuriating so I reached out to the owner and he said that on Jan 1st every year, the birth year is auto reset in the database to the current year so that none of retirees show their actual age, and this was done after too many hard feelings were made. SO... that could be why this works. Because they are all in fact 0 years old as the system thinks (note this is not an administrative database, it's just a web page for the residents to have fun with). So I'm sorry. You were correct. And yet, as I could see... it still works for what it's intended to do because of that lol. So now I'm curious though (not that I can see where I'll use it) but why would it not grab the year as well even if it was a different year? Just asking for my own education.
-
@ginerjm I'm not changing any topics. You said I'm not showing something so I explained why I didn't post the whole page. The code works. The year is irrelevant. I"m sorry if you don't believe it but that is no consequence to me. The code works. I don't know why it works, but for what I need it to do... it works. Thats all I know to explain. Remember, the idea of this was to show who has a birthday. It doesn't matter what year they are born. As long as it lists those whos month and day are that day of viewing, thats all that matters.
-
@ginerjm the part that echo's the results aren't included in this because there wasn't any problem with it. The problem I was having was only in the selecting. Filtering the results. The stuff that is printed to the page is extremely long that shows a bunch of birthday cakes pictures and their name and profile pictures and favorite hobbies and stuff like that. I didn't see it being relevant to post that since I was only asking to help filter the results by their birthday. If I posted all that other stuff then there would have been a whole bunch of coding that would have not been the point of the help at all. Hope that explains why I didn't put a bunch of clutter in my post
-
@Barand I also just saw something about a date fetch and thought I'd give it a try. I can't believe that this worked. I just made it to work with my page. But I would very much appreciate some education on WHY this is working? I like to learn instead of just copy and paste stuff. $datefetch = date("m/d/Y"); $sql = "SELECT * FROM `retirees` WHERE `birthday` = '$datefetch'";
-
@Barand I see. And yes since I really only need the birthday listing for this I changed it. I am getting "page isn't working" with it now though. I changed up the ' to " just in case (that is normally why I get that) and got the same results. I used the online trouble shooter and got Parse error: syntax error, unexpected identifier "birthday" in /tmp/preview on line 25 (this line 25 was with the db connection stuff typed in so it wont match a line 25 below but it's in the sql=select line) The column name that the birthdays are listed in is named birthday, so I'm not seeing where the problem is. It would be helpful if the error reporting also told why the page "isn't working". I don't have access to the server logs for this one. Any thoughts? <?Php error_reporting(E_ALL); ini_set('display_errors', '1'); //// db connection stuff here, removed for posting //// $conn = new mysqli($hostname, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = SELECT birthday FROM retirees WHERE MONTH(str_to_date(birthday, "%m/%d/%Y")) = MONTH(CURDATE()) AND DAYOFMONTH(str_to_date(birthday, "%m/%d/%Y")) = DAYOFMONTH(CURDATE()); if (!$result = $conn->query($sql)) { die ('There was an error running query[' . $conn->error . ']'); } ?>
-
@Barand thank you. I will test these out to see if I can get them to work when I get back to the computer in the morning. I appreciate it. From what I'm understanding, since my database is called "retirees" then I would have it like the following, and I choose the * so I can also include their name and favorite birthday cake that is listed. SELECT * FROM retirees WHERE MONTH(str_to_date(birthday, '%m/%d/%Y')) = MONTH(CURDATE()) AND DAYOFMONTH(str_to_date(birthday, '%m/%d/%Y')) = DAYOFMONTH(CURDATE()); and this will look for the birthdays that are on the current date at the time of looking at the webpage, because the string format is being converted and then it's looking for the current date and month, instead of the year too. Correct?
-
@Barand and @kicken Thank you much. For this one, I don't think it would be wise for me to convert values in the database because it's not mine. I'm only making a Birthday listing from it. If something went wrong, I wouldn't be able to change it back, or have access to import the database again. All I can do with this project is make a display page so I think I better not convert any data in it. I am looking into the LIKE thing now. Thank you for that. I think this will take me some time to figure out how to make it work specifically for what I need but I appreciate the direction. Thank you very much
-
I have an old database that has dates that are entered from a date picker. I don't have access to that database to change the structure of it because it's from an old partners website that told me "You can use it but I'm not messing with that stuff anymore" and wont give me the login info. (only giving a reason why I can't change that) TASK: To have a php page that selects the listings that are TODAY from the "birthday" column, so I can displays todays birthdays. However the column is VARCHAR instead of DATE I googled this but my googlie gunk only gave me results on a process to change the table structure and convert. Is there a way to select today, from the birthdays that are in today (not todays specific date, but like, tomorrow will be a new "today"... etc) The dates list like the following examples in the column "birthday" 01/15/1980 10/22/1989 11/09/1979 ... etc I'm not asking for anyone to write out a page for me. Just maybe something easier for me to follow than the google results I keep seeing that seems to assume everyone is an expert and can translate everything lol MANY THANKS!!!
-
Between what @requinix and @kicken posted and gave for references and things to focus on, and what I looked online, this is what I have so far. One pesky thing left is if there is no www or http or https and is, for example google.com side note... once I get this one figured out, I'm going to take on getting the default thumbnails for urls Any thoughts on that last bit? //If it has https// $comment= nl2br(preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $comment)); //if it doesn't have https// $comment= nl2br(preg_replace("#(^|[\n ])((www)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"https://\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $comment)); //Make the email address clickable to mailto stuff// $comment= nl2br(preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $comment)); //To turn the http into https// $comment= str_replace('http://', 'https://', $comment);
-
@Barand Thank you for changing the title for me. I was trying to correct that haha
-
@requinix You're right. I have a very backwards way of learning stuff. I suspect that stems from making radios and stuff when I was a kid, and just pairing wires (so to speak) that looked like other working radios till it worked, then I would be able to see why those connections worked. This isn't good practice for this. I'll try to change my habbits The text that is for the link is picked up automatically with this, from within the comment. So for example if the user enters I wanted to get my new shoes on sale but they are only discounted at https://www.shoes.com so I went to the website It would echo on the page I wanted to get my new shoes on sale but they are only discounted at https://www.shoes.com so I went to the website with the website as a link OH... and as I'm typing this, it looks like this forum is doing that too haha. Thats awesome. Okay so now I'm more confused than I thought I was. Where do I add the other options in that? Admittingly, the "https" is the only thing in all of that, that is recognizable to me haha
-
@requinix No I don't have that in there. This is what I tried (sorry I should have put this in the original post) $comment = nl2br(preg_replace_callback('~(\bhttps|http|www|mailto|.?://\S+)(?:\s+\[([^]]+)\])?~i', and $comment = nl2br(preg_replace_callback('~(\bhttps,http,www,mailto,.?://\S+)(?:\s+\[([^]]+)\])?~i', and $comment = nl2br(preg_replace_callback('~(\bhttps?://\S+)(?:\s+\[([^]]+)\])?~i', $comment = nl2br(preg_replace_callback('~(\bhttp?://\S+)(?:\s+\[([^]]+)\])?~i', $comment = nl2br(preg_replace_callback('~(\bwww?://\S+)(?:\s+\[([^]]+)\])?~i', $comment = nl2br(preg_replace_callback('~(\bmailto?://\S+)(?:\s+\[([^]]+)\])?~i', $comment = nl2br(preg_replace_callback('~(\b.?://\S+)(?:\s+\[([^]]+)\])?~i', But none of those worked