two variables with same value bind_param mysqli statement

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
chidge
Forum Commoner
Posts: 29
Joined: Sat May 10, 2008 4:03 pm

two variables with same value bind_param mysqli statement

Post by chidge »

so if I have the following:

Code: Select all

 
$i = $_GET['user_id']
$e = $_GET['user_email']
 
 
 
$query = "SELECT maintable.name, maintable.last, ideas.wicked, maintable.past_email, maintable.present_email
          FROM maintable
          LEFT JOIN ideas ON maintable.user_id = ideas.ideas_id
          WHERE (maintable.user_id=? AND maintable.present_email=?)
          OR (maintable.user_id=? AND maintable.past_email=?)";
 
 
$stmt = $conn->stmt_init();
if ($stmt->prepare($query)){
$stmt->bind_param("ssss", $i, $e, $i, $e);      
 
is there a better way to add the bind_param variables that have the same value?
(note this is just a snippet of code to illustrate this point)

thanks in advance
Post Reply