garydt Posted February 17, 2007 Share Posted February 17, 2007 I have a form where the user enters his name and creates his username and password, all of which are entered in a mysyql database. When users log in I want it to say 'Hello' and their name, but the recordset query isn't showing the name on the screen. Here;s the code- <?php require_once('Connections/registration.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_Recordset1 = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_registration, $registration); $query_Recordset1 = sprintf("SELECT fname FROM tablename1 WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $registration) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> Hello <?php echo $row_Recordset1['fname']; ?> <p> </body> </html> <?php mysql_free_result($Recordset1); ?> Link to comment https://forums.phpfreaks.com/topic/38932-displaying-recordset-query/ Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 looks like that MM_Username session field is never set so it skips the colname_recordset1 part Link to comment https://forums.phpfreaks.com/topic/38932-displaying-recordset-query/#findComment-187283 Share on other sites More sharing options...
garydt Posted February 17, 2007 Author Share Posted February 17, 2007 Thanks for the reply. Can you tell me what you mean by MM_Username is never set and how do i set it? (i am very new to php). When i got it to display MM_Username it worked. Have I set the recordset query correctly to search the database for the user that is currently logged on and then for it to search that row for the user's name (fname)? If i have then why won't it show the name? Link to comment https://forums.phpfreaks.com/topic/38932-displaying-recordset-query/#findComment-187310 Share on other sites More sharing options...
garydt Posted February 18, 2007 Author Share Posted February 18, 2007 Can anyone help? Link to comment https://forums.phpfreaks.com/topic/38932-displaying-recordset-query/#findComment-187880 Share on other sites More sharing options...
trq Posted February 18, 2007 Share Posted February 18, 2007 When users log in I want it to say 'Hello' and their name There should be no need to re-query the database for this infomation, when you login your users, store there username in the $_SESSION array. PS; Id'e definately recomend dropping Dreamweaver until youv'e learnt php. It writes terrible code and will teach you nothing. Link to comment https://forums.phpfreaks.com/topic/38932-displaying-recordset-query/#findComment-187888 Share on other sites More sharing options...
redarrow Posted February 18, 2007 Share Posted February 18, 2007 thrope correct i used dreamweaver on here when i start php progeamming it done me no good at all, i was advised the same drop dreamweaver so i did so, I used my good old free note pad and now i can do php programing properly. As time goes on and you get really good you can get a decent program from zend ok. good luck all the best redarrow Link to comment https://forums.phpfreaks.com/topic/38932-displaying-recordset-query/#findComment-187909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.