Passing get_current_user_id from one table to another…
-
I’d like my Users to have the ability to enter the names of basketball players into my custom data table, where I already have about 1,500 that are otherwise entered by me. They will have to be registered and logged in to use this form.
My Form is on a Page via a php INCLUDE (I use a lot of Includes so I can more easily manipulate code that I bring into my WP site). The Form posts to a php to handle the database entry. Everything works until I try to include the User_ID.
I get this error:
Fatal error: Call to undefined function get_current_user_id() in /home/jwrbloom/public_html/resources/playerEntry/dbEnter.php on line 6
Other than the php tags, below the entire code from the page.
$wp_userID = get_current_user_id(); <= Line 6 if(!$con = mysql_connect("localhost","###","###")) { die("Could not connect to database: ".mysql_error()); } mysql_select_db("jwrbloom_hhr", $con); $nameFirst = $_POST['nameFirst']; $nameLast = $_POST['nameLast']; $cityHome = $_POST['cityHome']; $school = $_POST['school']; $year = $_POST['year']; $position = $_POST['position']; $feet = $_POST['feet']; $inches = $_POST['inches']; $level = $_POST['level']; /* search for existing row */ $sql = "SELECT id FROM a_playerRank WHERE nameFirst='".mysql_real_escape_string($nameFirst)."' AND nameLast='".mysql_real_escape_string($nameLast)."' AND school='".mysql_real_escape_string($school)."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } if(mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); /* This tells us we already have him. */ {echo 'This player is already in the database. Hit back button if you need to enter another player.'; } } else { /* insert new row */ $sql = "INSERT INTO a_playerRank SET grouping='4', nameFirst='".mysql_real_escape_string($nameFirst)."', nameLast='".mysql_real_escape_string($nameLast)."', city='".mysql_real_escape_string($cityHome)."', school='".mysql_real_escape_string($school)."', year='".mysql_real_escape_string($year)."', position='".mysql_real_escape_string($position)."', feet='".mysql_real_escape_string($feet)."', inches='".mysql_real_escape_string($inches)."', level='".mysql_real_escape_string($level)."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); // Email to me $message = $_POST['nameFirst'] . " " . $_POST['nameLast'] ." was added to the database.\n"; $message .= $_POST['feet'] . "'" . $_POST['inches'] ."\", " . $_POST['year'] . "; " . $_POST['school'] ."\n"; $message .= $_POST['position']."\n"; $message .= $_POST['email']; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); $headers = "From: HHR Database Entry <[email protected]>"; // Send mail('[email protected]', 'Player database addition', $message, $headers); /* redirect user */ header("Location:https://hoosierhoopsreport.com/dbpe"); } }
I tried using a Global call. I’ve tried a require_once at the beginning. I’ve tried moving get_current_user_id to a few different places.
- The topic ‘Passing get_current_user_id from one table to another…’ is closed to new replies.