Jump to content

Recommended Posts

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:

Quote

Warning: include(ABSPATHresources/con.php): failed to open stream: No such file or directory in /home2/csi/public_html/resources/rankings_navigation_process.php on line 2
 

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.

Edited by Jim R
1 hour ago, gw1500se said:

Since you don't say what ABSPATH is, I am guessing there is a missing '/' in the resulting string.

 

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.

3 minutes ago, gw1500se said:

echo ABSPATH ."resources/con.php";

Let's look at the resulting string. Then verify that is it correct and if the file does exist, has the right permissions.

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.  

Edited by Jim R

So it is now clear that ABSPATH is not being substituted the way you expect. How is it defined and where? I don't normally use constants but somewhere you must have a "define('ABSPATH',<whatever>);" but is not executed before that include.

Edited by gw1500se
  • Like 1
30 minutes ago, gw1500se said:

So it is now clear that ABSPATH is not being substituted the way you expect. How is it defined and where? I don't normally use constants but somewhere you must have a "define('ABSPATH',<whatever>);" but is not executed before that include.

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?  

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.

image.png.3acb7ab093d756cbf86fd2d651daf013.png

But where does that constant (ABSPATH) actually get setup?  Apparently the set of modules in use during this process is missing something that sets the constant up.  Your other uses must be setting it.  For some reason this use is not doing that.  Something's missing.

6 minutes ago, ginerjm said:

But where does that constant (ABSPATH) actually get setup?  Apparently the set of modules in use during this process is missing something that sets the constant up.  Your other uses must be setting it.  For some reason this use is not doing that.  Something's missing.

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();
  }

 

Edited by Jim R
1 minute ago, ginerjm said:

I don't see what that "con.php" code you just posted has to do with this particular constant.....

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. 

4 minutes ago, ginerjm said:

Proves nothing.  My original post is still the problem you need to research.

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.

 

Edited by Jim R
11 minutes ago, gw1500se said:

try this:


include("/home2/csi/public_html/resources/con.php");

 

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. 

Edited by Jim R
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.