• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

QUESTION mysqli Prepared statement not working in Universal Snippet

Messages
5
Likes
0
Points
1
#1
Hello,

I am using a function in PHP to prepare a mysql SELECT statement and it seems to be failing on one line of code. What am I doing wrong?

Code:
    function loadCounty(){
    $sqlCounty = "SELECT id, county_name FROM wp_counties WHERE state_id=? ORDER BY county_name ASC";
    $stmt = $_SESSION["link"]->prepare($sqlCounty);
    $stmt->bind_param("i", $_SESSION[State]);
    $stmt->execute();
    $resultC = $stmt->get_result(); // This is the code causing my snippet to fail
    return $resultC;
    }
 

Temyk

Developer & Support
Staff member
Messages
744
Likes
32
Points
28
#2
Hello.

$_SESSION[State]
must be
$_SESSION['State']

If it doesn't help, look for a logical error in the code.