Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to dynamically select email address from database?
    primarykey
    data
    text
    <p>I am using the following PHP code to send email whenever the record is inserted into the table. </p> <pre><code>&lt;?php $latitude = $_GET['latitude']; $longitude = $_GET['longitude']; $uid = $_GET['uid']; $type = $_GET['type']; $server = "itp.db.8307610.hostedresource.com"; $username = "abc"; $password = "xyz"; $database = "abc"; $query = "INSERT INTO gps (latitude, longitude, uid, type) VALUES ($latitude, $longitude, $uid, '$type')"; $query1 = "SELECT email FROM musers WHERE uid = $uid"; $result = mysqli_query($link,$query1) or die("query error".mysqli_error()); $email = mysqli_fetch_array($result, MYSQLI_ASSOC); @mail("$email","New record added","A new record has been added,"From: info@xyz.com"); $link = mysqli_connect($server, $username, $password) or die ("error connecting to database"); mysqli_select_db($database, $link); mysqli_query($query, $link) or die("query error"); mysqli_query($query1, $link) or die("query error"); mysqli_close($link); echo "SUCCESS\n"; ?&gt; </code></pre> <p>This works without a problem. I have hard coded the email id.<br> How can I dynamically add email from musers table based on the following query.</p> <pre><code>select email from musers where uid = $uid; </code></pre> <p><strong>EDIT:</strong> I am getting the following error after making the changes. </p> <blockquote> <p>Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/content/i/t/p/itp/html/data/email.php on line 12</p> <p>Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/content/i/t/p/itp/html/data/email.php on line 12 query error</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload