Jim R
Members-
Posts
988 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Jim R
-
So the AJAX is in addition to the form and query? I've never dealt with if ($_SERVER['REQUEST_METHOD']==='POST') while having the form method being a file.
-
ha...so the query is good, but the placement isn't. It is inside the loop that's creating this table... I have a + image trying to replace the Submit button (working on that), and I have it put next to each player's name. My thinking after seeing the simple INSERT query produce 64 rows (one for each player), was creating the join with a_players on the insert so I could create one match. (The ID number showing was just my way of knowing it was being passed.
-
$query = "INSERT INTO a_player_bookmark (playerID,bookmark) VALUES ('".$pid."', 1) "; It's producing correct values for 64 rows.
-
I tried it without the join and got the same result. It posted the correct playerID and bookmark = 1...64 rows.
-
No, I'm trying to insert one row of data for each submit, allowing the User to bookmark a player to follow.
-
Just one, and not even any of the ones on that particular query. So my understanding of what I have is the SELECT instances are the values for playerID and bookmark. If not, then I'm mistaken on what that query is doing. I Googled php, mysql, insert, join. Found about six or seven resolved questions on a couple of different places. They all had that syntax, without any explicit VALUES terms, so I assumed what was in that SELECT were the values being inserted.
-
I got my code to work without an error, and I thought I would be able to expand on that by Joining my a_players table so I can match the player's ID. Figured out the syntax of it (I think), but instead of just inserting one row for the playerID, it inserts the playerID for every possible row. In this case 64 rows. So I get 64 rows of bookmark = 1 playerID = 251 (for example) - hidden data if (isset($_POST['bookmark'])) { $pid = $_POST['pid']; include("/home2/csi/public_html/resources/con.php"); $query = "INSERT INTO a_player_bookmark (playerID,bookmark) SELECT p.id, 1 FROM a_players p WHERE p.id = '" . $pid . "' "; $results = mysqli_query($con,$query); echo mysqli_error($con);
-
Just dawned on me (isset($_POST['submit'])) needs to be the name of the button, not the type. It otherwise works.
-
It was all PHP code.
-
It's just that above, which then feeds into... function player_name ($nameFirst,$nameLast) { echo '<a href="/tag/'. strtolower($nameFirst) . '-' . strtolower($nameLast) .'">'. $nameFirst . ' ' . $nameLast .'</a> '; echo '<span>' . bookmark_add() . '</span>'; } Once I get it done, it won't be bookmark_add() in there. It will just be bookmark_choose(). I'll have to determine if the bookmark is chosen or not. Right now, I'm just trying to see why the query isn't working.
-
That's what I was doing, and it didn't work. I'm not sure if it's not working because of the query or if it's because it just won't work as I have it set up. Right now I have this all in a Function in a functions files, then referring to it on my main page.
-
(I'm told all the time not put full name data in multiple tables. I get it. I'm slowly drifting more in that direction. Problem is, I often need to quickly get to data in my phone, and setting queries with joins isn't always feasible, and I also have a couple of people who can view my database who zero idea how to use it other than like a spreadsheet. I'm not dealing with big data. That's why I added the explanation in ( ), to let you know why I was doing that.) The form is only going to have the Submit button, which I plan on using a image for. I just to make sure for now I can add the row and keep the User at the same spot. They're going to have this option wherever the Item is listed (about four different spots). So you think I should send it to it's own file to process, then back? I've done a lot with forms that get sent to a file to execute a database query, then moved the User back or to the different page. I just thought it could all in the same place.
-
Ultimately I will be adding three columns: itemID, userID, username (so I can easily look at it on my phone). I'm creating a bookmark for an item for each User. I've not messed with AJAX much.
-
Looking to INSERT a row in a data table and keeping the User on the current page. Will it work like what I have below, or do I need to send it to its own page then return the User back to where he started? What I have below isn't inserting a row. No errors showing. function bookmark_add () { if (isset($_POST['submit'])) { include("/home2/csi/public_html/resources/con.php"); $query = "INSERT INTO a_player_bookmark (bookmark) VALUES ('1')"; $results = mysqli_query($con,$query); echo mysqli_error($con); } $output = '<form name="bookmark_add" method="post" action="" class="bookmark-plus">'; $output .= '<span><input type="submit" name="Bookmark"></span>'; $output .= '</form>'; return $output; }
-
I moved it over to the MySQL board, and I think we have it figured out. I didn't have a lone processing the query.
-
Got it...thank you! I did forget that line. I'll likely come up with another hitch. 😐
-
I'm wanting to insert the following when someone submits a form. I know I have a connection to the database, and I know grade and position are coming from the form. $grade = $_POST['grade']; $position = $_POST['position']; $query = "INSERT INTO a_rankings_select (grade,position) VALUES ('" .$grade. "', '" .$position. "')"; echo mysqli_error($con);
-
Will do.
-
Seemed like that should've been the first thing we tried, but in the past that has triggered errors. A long time ago I was told by WP people not to use that. I don't recall the reason. However, the query still isn't working. $query = "INSERT INTO a_rankings_select (grade,position) VALUES ('" .$grade. "', '" .$position. "')"; I removed the variables from above I'm not ready to insert just yet.
-
I give it the path in the settings which is the base URL, and it accesses the database in the wp-config.php via localhost and my account information. I assume it draws the rest of the actual path, which for this site is /home2/csi/public_html/. I know that to be accurate. I checked it with my server.
-
I was just posting it so you know what any include I use to connect to my database uses that exact same code. So nothing is different on what I control between what is working and what isn't working.
-
-
I get what you're saying, but all those instances Include the same con.php file. It's set up with WordPress. Let me see if I can find it... con.php $con = mysqli_connect("localhost","###username","##password", "###database"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
-
At the bottom. con.php. resources menu at courtsideindiana.com. That's where the file is. It's been there for three years, and other places on the site are using it. Meanwhile I use ABSPATH in other locations too in my resources file, and they also are working. It's just this instance that isn't work.
-
Same error, and I had already tried Require and Require_once. Why would it work in all the other instances but not that one?