digitalgod Posted May 19, 2006 Share Posted May 19, 2006 hey guysnot sure how to explain this so I'll show you what I have so far.I have members.php that contain[code]//......$tmpl->add_template("main");$a=(isset($_GET['a']) ? $_GET['a'] : 'default');$uname = $_GET['user']; switch($a) { case "editprofile": $process=$_POST['process']; if ($process == "yes") { $process_b=$_POST['process_b']; $username=$_POST['username']; if ($process_b == "yes") { $new_email=$_POST['new_email']; $new_name=$_POST['new_name']; if (strlen($new_uname) < 5 || strlen($new_email) < 6 || strlen($new_name) < 3) { $tmpl->add_template("editprofile_tooshort"); } else { mysql_query("UPDATE ".$prefix."users SET username='$new_uname',email='$new_email',realname='$new_name' WHERE username='$username'") or die(query_error()); $tmpl->add_template("editprofile_success"); } } else { } } else { $result=mysql_query("SELECT * FROM ".$prefix."users WHERE username='".$uname."'") or die(query_error()); $row=mysql_fetch_array($result); if ($row['id'] != "") { $tmpl->add_template("editprofile_form"); } } break; case "viewprofile": $tmpl->add_template("viewprofile"); break; }//.......[/code]so when a person clicks on Edit Profile it takes them to this form (editprofile_form.php)[code]<div id="article"><form action="members.php?a=editprofile" method="post"><input type="hidden" name="process" value="yes" /><input type="hidden" name="process_b" value="yes" /><input type="hidden" name="username" value="<?php echo $username; ?>" /><table border="0"><tr><td> </td><td> </td></tr><tr><td>Email:</td><td><input type="text" name="new_email" value="<?php echo $row['email']; ?>" maxlength="150" /></td></tr><tr><td>First name:</td><td><input type="text" name="new_name" value="<?php echo $row['fname']; ?>" maxlength="75" /></td></tr><tr> <td>Last name:</td> <td><input type="text" name="new_name2" value="<?php echo $row['lname']; ?>" maxlength="75" /></td></tr><tr>//.....[/code]my problem is that the input boxes don't show any value..... I know I'm querying the right table and that the rows exist and have info in them so why are the boxes empty...?any help would be greatly aprecaited*edit*if I place echo $row['email']; in members.php it works perfectly so why doesn't it work in the form...? Quote Link to comment https://forums.phpfreaks.com/topic/10030-mysql-query-help/ Share on other sites More sharing options...
ryanlwh Posted May 19, 2006 Share Posted May 19, 2006 You have $uname here, which i suspect should be $username.[code]$result=mysql_query("SELECT * FROM ".$prefix."users WHERE username='".$uname."'")[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37283 Share on other sites More sharing options...
digitalgod Posted May 19, 2006 Author Share Posted May 19, 2006 [!--quoteo(post=375354:date=May 19 2006, 05:13 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ May 19 2006, 05:13 PM) [snapback]375354[/snapback][/div][div class=\'quotemain\'][!--quotec--]You have $uname here, which i suspect should be $username.[code]$result=mysql_query("SELECT * FROM ".$prefix."users WHERE username='".$uname."'")[/code][/quote]$uname is just a variable where the username is stored$uname = $_GET['user'];so I don't think that's the problem Quote Link to comment https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37286 Share on other sites More sharing options...
dsk3801 Posted May 20, 2006 Share Posted May 20, 2006 What is this doing:$tmpl->add_template("editprofile_form");If you're using a template system of some kind, it would depend on how that template system handles PHP code within the templates. Does the add_template() method read in the template file using fread or something similar or does it include() the template file? If it is using something like fread to get the contents of the file, the PHP inside would not be processed. Quote Link to comment https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37367 Share on other sites More sharing options...
digitalgod Posted May 20, 2006 Author Share Posted May 20, 2006 [!--quoteo(post=375440:date=May 19 2006, 11:30 PM:name=Dave K.)--][div class=\'quotetop\']QUOTE(Dave K. @ May 19 2006, 11:30 PM) [snapback]375440[/snapback][/div][div class=\'quotemain\'][!--quotec--]What is this doing:$tmpl->add_template("editprofile_form");If you're using a template system of some kind, it would depend on how that template system handles PHP code within the templates. Does the add_template() method read in the template file using fread or something similar or does it include() the template file? If it is using something like fread to get the contents of the file, the PHP inside would not be processed.[/quote]hey Dave, it simply include() the template file[code]session_start();//// Build the template class//class Template {var $errors;var $cur_page_name; // // Create the add_template() function // function add_template($template_name) { $template_name=$template_name.".php"; // // If the template name is blank... // if ($template_name == ".php") { print("Error loading template.<br />\n"); $this->errors++; } else { // // The file exists, so output the data // if (file_exists("template/".$this->cur_page_name."/".$template_name)) { include("template/".$this->cur_page_name."/".$template_name); } // // If it doesn't, don't output the data // else { print("That template doesn't exist.<br />\n"); $this->errors++; } } }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37415 Share on other sites More sharing options...
digitalgod Posted May 21, 2006 Author Share Posted May 21, 2006 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37557 Share on other sites More sharing options...
.josh Posted May 21, 2006 Share Posted May 21, 2006 i think the problem is with the scope of $row. please refer to [a href=\"http://www.php.net/include/\" target=\"_blank\"]http://www.php.net/include/[/a] for info on the scope of variables when mixing includes and functions. Quote Link to comment https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37562 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.