
Jim R
Members-
Posts
1,006 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Jim R
-
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?
-
That's how WordPress uses it, and the page it redirects from to process the form uses the same file. What should it show when I print that?
-
I'm not sure I follow, but with that echo there, this is the result: ABSPATHresources/con.php
-
It is correct. The file exists. It has the right permissions. It's the same file being used by many other queries in other functions and files on the same site. EDIT: Hold on...I misread what you wrote.
-
The file that allegedly doesn't exist... include(ABSPATH ."resources/con.php");
-
That's not it. There is a trailing / in the ABSPATH. This is line of code in a file that is included for several functions which are currently working as expected, as well as similar instances on other sites I've developed.
-
This is a strange one, as I have many forms on my various sites, and on this site, the file in question is used by several functions. Ultimately, I'm wanting it INSERT values from the form, which I'll eventually add more of. Form is process and is stent to rn_process.php, which is the code listed below. include(ABSPATH ."resources/con.php"); $grade = $_POST['grade']; $position = $_POST['position']; echo $grade.$position; $query = "INSERT INTO a_rankings_select (username,userID,grade,position) VALUES ('" .$username. "', '" .$userID. "', '" .$grade. "', '" .$position. "')"; It echoes the correct $grade and $position when I comment out the INCLUDE. So I know it's passing the correct values. However, when the INCLUDE is active, I get the following error: resources/con.php is a file I link to many times, and it's work in those instances. It's certainly not executing the INSERT.
-
I appreciate that, but I'm trying to avoid typing all of that in the future, especially in regards to a player's name.