ok problem is i have a table that gets a list of all ps in the database and it get the id of teh memer it was sent to and sent by
it then uses that id number to get the member name to display it in the table problem is php cant read a variable but can read the table name directly?:
for reference --> $table3 = "scms_users"
not working code:
<?php
include "../config.php3";
include "../dbconnect.php3";
function gettoname($pmto){
$rows1 = mysql_query("SELECT * FROM $table3 WHERE id=$pmto") or die ("here it is");
while ($b1 = mysql_fetch_array($rows1)or die(mysql_error())){
$pmname = $b1['username'];
return $pmname;
}}
function getfromname($pmfm){
$rows1 = mysql_query("SELECT * FROM $table3 where id='$pmfm'") or die (mysql_error());
while ($b1 = mysql_fetch_array($rows1)or die(mysql_error())){
$fmname = $b1['username'];
return $fmname;
}}
?>
working code:
<?php
include "../config.php3";
include "../dbconnect.php3";
function gettoname($pmto){
$rows1 = mysql_query("SELECT * FROM scms_users WHERE id=$pmto") or die ("here it is");
while ($b1 = mysql_fetch_array($rows1)or die(mysql_error())){
$pmname = $b1['username'];
return $pmname;
}}
function getfromname($pmfm){
$rows1 = mysql_query("SELECT * FROM scms_users where id='$pmfm'") or die (mysql_error());
while ($b1 = mysql_fetch_array($rows1)or die(mysql_error())){
$fmname = $b1['username'];
return $fmname;
}}
?>
so somehow php can't execute the query with a variable as the table?