portal123
asked on
Problem, How to get a value from MySQL table
I have a question to get one value from a table called tblenzo_meladmin in MySQL and then I would like to pack this value into Email function. I used my_fetch_assoc() function to grab a value from a record in a table.
To send Email is O.K, but I've got error message like follows
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/users/13and12/public _html/stor e_based_ne wsletters/ transact_m alma.php on line 93
And my code is as follows:
$sql_sel = "select emailaddress from tblenzo_client where uid2=$_SESSION[uid2]";
$rst_sel = mysql_query($sql_sel,$con) ;
$sql_admin_email = "select s_email from tblenzo_meladmin where uid=$_SESSION[uid2]";
$rst_admin_email = mysql_query($sql_admin_ema il,$con);
line93 $col_admin_email = mysql_fetch_assoc($rst_adm in_email);
$subject = $_POST['subject'];
$msg = $_POST['news'];
while($col=mysql_fetch_arr ay($rst_se l)){
$mailform="From:" .mb_encode_mimeheader("exe 123") ."<".$col_admin_email.">";
mb_send_mail($col['emailad dress'], $subject,$msg,$mailform);
}
If you help me out, I really appreciate it.
Thanks and Best Wish, portal123
To send Email is O.K, but I've got error message like follows
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/users/13and12/public
And my code is as follows:
$sql_sel = "select emailaddress from tblenzo_client where uid2=$_SESSION[uid2]";
$rst_sel = mysql_query($sql_sel,$con)
$sql_admin_email = "select s_email from tblenzo_meladmin where uid=$_SESSION[uid2]";
$rst_admin_email = mysql_query($sql_admin_ema
line93 $col_admin_email = mysql_fetch_assoc($rst_adm
$subject = $_POST['subject'];
$msg = $_POST['news'];
while($col=mysql_fetch_arr
$mailform="From:" .mb_encode_mimeheader("exe
mb_send_mail($col['emailad
}
If you help me out, I really appreciate it.
Thanks and Best Wish, portal123
You connected to the mysql server before releasing the query, right?
(with mysql_connect();).
Change : $sql_sel = "select emailaddress from tblenzo_client where uid2=$_SESSION[uid2]";
To : $sql_sel = "select emailaddress from tblenzo_client where uid2=".$_SESSION["uid2"];
and, if it still doesn't work, change : $rst_sel = mysql_query($sql_sel,$con) ;
to : $rst_sel = mysql_query($sql_sel,$con) OR print mysql_error()."<p>$sql_sel ";
You ll see the error message returned by mysql and also your sql query.
(with mysql_connect();).
Change : $sql_sel = "select emailaddress from tblenzo_client where uid2=$_SESSION[uid2]";
To : $sql_sel = "select emailaddress from tblenzo_client where uid2=".$_SESSION["uid2"];
and, if it still doesn't work, change : $rst_sel = mysql_query($sql_sel,$con)
to : $rst_sel = mysql_query($sql_sel,$con)
You ll see the error message returned by mysql and also your sql query.
also:
$sql_sel = "select emailaddress from tblenzo_client where uid2=$_SESSION[uid2]";
$rst_sel = mysql_query($sql_sel,$con) ;
should be:
$sql_sel = "select emailaddress from tblenzo_client where uid2={$_SESSION['uid2']}";
$rst_sel = mysql_query($sql_sel,$con) ;
-Geir
$sql_sel = "select emailaddress from tblenzo_client where uid2=$_SESSION[uid2]";
$rst_sel = mysql_query($sql_sel,$con)
should be:
$sql_sel = "select emailaddress from tblenzo_client where uid2={$_SESSION['uid2']}";
$rst_sel = mysql_query($sql_sel,$con)
-Geir
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all guys and jasco4617 .
it was my simple miss spelling:
$sql_admin_email = "select s_email from tblenzo_meladmin where uid=$_SESSION[uid2]";
Should be - $sql_admin_email = "select s_email from tblenzo_meladmin where uid=$_SESSION[uid2]";
b.w, portal123
it was my simple miss spelling:
$sql_admin_email = "select s_email from tblenzo_meladmin where uid=$_SESSION[uid2]";
Should be - $sql_admin_email = "select s_email from tblenzo_meladmin where uid=$_SESSION[uid2]";
b.w, portal123
what is the difference in those two strings?
-Geir
-Geir
$sql_admin_email = "select s_email from tblenzo_meladmin where uid=$_SESSION[uid2]";
$rst_admin_email = mysql_query($sql_admin_ema
$col_admin_email = mysql_fetch_assoc($rst_adm
to this:
$sql_admin_email = "select s_email from tblenzo_meladmin where uid={$_SESSION['uid2']}";
$rst_admin_email = mysql_query($sql_admin_ema
$col_admin_email = mysql_fetch_assoc($rst_adm
That should fix your query error.
You could also change:
$rst_admin_email = mysql_query($sql_admin_ema
to:
$rst_admin_email = mysql_query($sql_admin_ema
-Geir