Parameter Passing (PHP)

kristinhot

New Member
I am trying to select a record in a database. I am having a problem with the function runSelect (function is to select a record in the database) I believe it might be with how I am passing my variables in the functions. \[code\] function select($pUserData){ echo "I am in function select." . "<br/>"; // Create the SQL query $sqlQuery = "SELECT * FROM tablName WHERE id= " . $pUserData[0]; $con = openConnection(); $result = $con->query($sqlQuery); $row = $result->fetch_row(); echo "hello"; echo "ID: " . $row[0] . "<br />"; echo "First Name: " . $row[1] . "<br />"; // Close connection closeConnection($con); } function openConnection() { $connection = new mysqli("localhost", "userName", "password", "databaseName"); if ( mysqli_connect_errno() ) { echo "Error: Could not connect to database. Please try again later. " . "<br/>"; } echo "in openConnection" . "<br/>"; return $connection; } function closeConnection($pCon) { $pCon->close(); } ?>\[/code\]
 
Back
Top