Jump to content

proctk

Members
  • Posts

    300
  • Joined

  • Last visited

    Never

Everything posted by proctk

  1. I'm trying to create the table with the pode I posted. I'm having a hard time creating the table with the FKs note the error message I posted above
  2. here is some more information.  I have learned a bit more but having a hard time creating the table Below is code that I'm trying to use to create a master table. the code returns error: Create table Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOREIGN KEY (parent) REFERENCES parent(parent_id) FOREIGN KEY (sibling) REFER' at line 4 Anything standing out. Also, once this works will it auto copy the information from tables that is haveing data added or do I have to edit my code to send information to the tables to send  the PK to the master table any help guidance is great. As you tell my knowledge is limited [code=php:0] <? include 'db.php'; mysql_query("CREATE TABLE master (   master int(25) NOT NULL auto_increment,   FOREIGN KEY (users) REFERENCES users(user_id)   FOREIGN KEY (parent) REFERENCES parent(parent_id)   FOREIGN KEY (sibling) REFERENCES sibling(sibling_id)   FOREIGN KEY (children) REFERENCES children(children_id)   PRIMARY KEY  (master) )")or die("Create table Error: ".mysql_error()); ?> [/code]
  3. Hi I have setup a data base and from reading and feedback on forums. My design is not great and causing me some greif. I have five tables and U want to get join then for certain query.  I read that I should creat an assocate table which had the PK for each table in it.  The part that I'm having a hard time understanding is how to populate the PKs in the assocate table as FK.  Once this s done, how would I use the associate table to pull the information out of the tables any help or times is great.  tables [Code] [u] children[/u] child_id(pk) childfirstname childlastname childdob [u]sibling[/u] sibling_id(pk) sibfirstname siblastname [u] spouse[/u] spouse_id(pk) spousefirstname spouselastname [u]users[/u] user_id(pk) userfirstname userlastname username associate table [i]aboutMe[/i] aboutme_id(pk) child_id(fk) spouse_id(fk) sibling_id(fk) [/code]
  4. I have sent all ay working on this issue. It turns out my database table design is not great.  I'm trying to figureout how to create master table to hold myall  my tables primary keys in assocate table - don't have a clue how to set this up mytables about me aboutme_id(pk) child_id(fk) spouse_id(fk) sibling_id(fk) any pointers where I can find information on this
  5. I think that I have an idea what is wrong, It's looking for the username in all tables and when it finds a match it repeats the print the data each time I  only want each match to print once
  6. Hi It dislays the information but repeats it 6 times when there is only one entery in the database. I have no idea why this is happening, its doing the samething it did when I assigned the columns to variables
  7. I made the changes and I get the  same error message.  I place a } just before mysql_close ().  I double checked the column names, all looks good. updated code [code=php:0] <? include 'db.php'; $username = $_SESSION['username']; $query = ("SELECT * FROM children, spouse, sibling, aboutMe, users WHERE children.username = '$username' AND spouse.username = '$username' AND sibling.username = '$username' AND  aboutMe.username = '$username' AND users.username = '$username'"); $result = mysql_query($query) or die(mysql_error()); $num = mysql_numrows($result); while ($row = mysql_fetch_array($result, MYSQL_ASSOC) or die(mysql_error() {     echo '<p class=".$row['spousesex']."><b>First Name:</b> '.$row['spousefirstname'].'<br>     <b>Last Name:</b> '.$row['spouselastname'].'<br>     <b>DOB:</b> '.$row['spousedob'].'<br>     </p><br>'; } mysql_close(); ?> [/code]
  8. and I drag this on, error Parse error: parse error, unexpected '{' in C:\MyServer\xampp\htdocs\NewStuff\familypages\myFamily.php on line 51. the first line of code is line 51 updated code [code=php:0] $username = $_SESSION['username']; $query = ("SELECT * FROM children, spouse, sibling, aboutMe, users WHERE children.username = '$username' AND spouse.username = '$username' AND sibling.username = '$username' AND  aboutMe.username = '$username' AND users.username = '$username'"); $result = mysql_query($query) or die(mysql_error()); $num = mysql_numrows($result); while ($row = mysql_fetch_array($result, MYSQL_ASSOC) or die(mysql_error() {     echo '<p class=".$row['spousesex']."><b>First Name:</b> '.$row['spousefirstname'].'<br>     <b>Last Name:</b> '.$row['spouselastname'].'<br>     <b>DOB:</b> '.$row['spousedob'].'<br>     </p><br>'; mysql_close(); ?> [/code]
  9. I get this eror message Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\MyServer\xampp\htdocs\NewStuff\familypages\myFamily.php on line 52
  10. Below is code that I'm trying to use get data from tables in my database and assign each column to a variable.  The row to get the information from is determined by the username. I used the same code to get information from individual tables and it works fine but for some reason its echoing double enteries for each row. The biggest change is the query selecting the tables any help is great [code=php:0] <? include 'db.php'; $username = $_SESSION['username']; $query = ("SELECT * FROM children, spouse, sibling, aboutMe, users WHERE children.username = '$username' AND spouse.username = '$username' AND sibling.username = '$username' AND  aboutMe.username = '$username' AND users.username = '$username'"); $result = mysql_query($query) or die(mysql_error()); $num = mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $fistname = mysql_result($result,$i,"childfirstname"); $lastname = mysql_result($result,$i,"childlastname"); $dob = mysql_result($result,$i,"childdob"); $sex = mysql_result($result,$i,"childsex"); $userid = mysql_result($result,$i,"userid"); $age = round(dateDiff("/", date("m/d/Y", time()), $dob)/365, 0); $momFirstName = mysql_result($result,$i,"momFirstName"); $momLastName = mysql_result($result,$i,"momLastName"); $momDob = mysql_result($result,$i,"momDob"); $dadFirstName = mysql_result($result,$i,"dadFirstName"); $dadLastName = mysql_result($result,$i,"dadLastName"); $dadDob = mysql_result($result,$i,"dadDob"); $anniversaryDate = mysql_result($result,$i,"anniversaryDate"); $maddenName = mysql_result($result,$i,"maddenName"); $siblingfistname = mysql_result($result,$i,"siblingfirstname"); $siblinglastname = mysql_result($result,$i,"siblinglastname"); $siblingdob = mysql_result($result,$i,"siblingdob"); $siblingsex = mysql_result($result,$i,"siblingsex"); $spousefistname = mysql_result($result,$i,"spousefirstname"); $spouselastname = mysql_result($result,$i,"spouselastname"); $spousedob = mysql_result($result,$i,"spousedob"); $spousesex = mysql_result($result,$i,"spousesex"); echo "<p class='$spousesex'><b>First Name:</b> $spousefistname<br> <b>Last Name:</b> $souselastname<br> <b>DOB:</b> $sousedob<br> <b>Age:</b> $spouseage<br> <a href='Updatespouse.php?id=$userid'>Edit</a> <a href='deleteSpouse.php?id=$userid'>Delete</a> </p><br>"; $i++; } ?> [/code]
  11. I'm a rookie, everything I have learned is from tutorials, and some code is copied and edited.
  12. I want the form fields value to be set but a value in the table. the form field Date of Birth would be populated with the persons DOB in the database.
  13. Hi I have a form that is used to update registered users information.  I want the form to populate with the users information from the database table so that they can see current info before updating I use the below code to display the logged in regestered users information but I cannot figure out how to assign the users information to variables that i can set to equal form values. any help is great code to get users information [code=php:0] <? include 'db.php'; $username = $_SESSION['username']; // note, if userid is not a numeric type column, then $userid must be quoted $query = "SELECT * FROM users WHERE username = '$username'"; $result = @mysql_query($query); if(!$result) {   trigger_error("<p>SQL ERROR:<br>".mysql_error()."<br>Query: $query</p>",                 E_USER_WARNING); } elseif(mysql_numrows($result) != 1) {   trigger_error("<p>DB ERROR: There were multiple matches on this User ID</p>",                 E_USER_WARNING); } else  // we got exactly one match on the User ID {   echo "<b><center>Database Output</center></b><br><br>";     // only 1 match, so we don't need a loop   $row = mysql_fetch_assoc($result);   extract($row, EXTR_PREFIX_ALL, "user");   mysql_close();     echo <<<END   <b>$user_first_name $user_last_name</b><br> Date of Birth: $user_DOB<br> <b>Address</b><br> Street Address: $user_Street_address<br> Other Mailing Information: $user_post_office_box<br> City: $user_city <br> Province: $user_province<br> Postal Code: $user_postal<br> Home Phone Number: $user_home_phone<br> Email Address: $user_email_address<br> Family Relationship: $user_familyRelationship<br> <hr><br> END; } ?> [/code]
  14. Hi I have been working through the above tutorial. I have been able to get everything to work except the password recovery utility. I created the form see below any thought why this is not working <body> <form id="form1" name="form1" method="post" action="codeLostPassword.php">   <label for="textfield">Email Address:</label>   <input type="text" name="email_address" id="email_address" />   <input name="hiddenField" type="hidden" value="recover" />     <input type="submit" name="Submit" value="Submit" id="Submit" /> </form> </body> and made a few changes to the code for regenerating the password. (file names only) [code=php:0] <?php session_start(); ?> <? include 'db.php'; switch($_POST['recover']){     default:     include 'lost_pw.php';     break;         case "recover":     recover_pw($_POST['email_address']);     break; } function recover_pw($email_address){     if(!$email_address){         echo "You forgot to enter your Email address             <strong>Knucklehead</strong><br />";         include 'lost_pw.php';         exit();     }     // quick check to see if record exists        $sql_check = mysql_query("SELECT * FROM users WHERE email_address='$email_address'");     $sql_check_num = mysql_num_rows($sql_check);     if($sql_check_num == 0){         echo "No records found matching your email address<br />";         include 'lost_pw.php';         exit();     }     // Everything looks ok, generate password, update it and send it!         function makeRandomPassword() {           $salt = "abchefghjkmnpqrstuvwxyz0123456789";           srand((double)microtime()*1000000);           $i = 0;           while ($i <= 7) {                 $num = rand() % 33;                 $tmp = substr($salt, $num, 1);                 $pass = $pass . $tmp;                 $i++;           }           return $pass;     }     $random_password = makeRandomPassword();     $db_password = md5($random_password);         $sql = mysql_query("UPDATE users SET password='$db_password'                 WHERE email_address='$email_address'");         $subject = "Your Password at MyWebsite!";     $message = "Hi, we have reset your password.         New Password: $random_password         http://www.mywebsite.com/login.php         Thanks!     The Webmaster         This is an automated response, please do not reply!";         mail($email_address, $subject, $message, "From: MyDomain Webmaster<admin@mydomain.com>\n         X-Mailer: PHP/" . phpversion());     echo "Your password has been sent! Please check your email!<br />";     include 'login.php'; } ?> [/code]
  15. HI I have been searching the web for an easy to follow tutorial to create and Expanding and Collapsing Menu bar(horizontal). The post popular search result is the tutorial posted on phpfreaks, my php skills are limited and I find this tutorila hard to follow. anything is a great start thank you
  16. Below is code that I'm using to display a users information . I'm trying to figure out how I can change this so that it can be used to update a users information via a form call UpdateMyInformation.php thank you for any help [code] <?php session_start(); ?> <html> <head> <title>Get My Info</title> </head> <body> <? include 'db.php'; $username = $_SESSION['username']; echo($username); // note, if userid is not a numeric type column, then $userid must be quoted $query = "SELECT * FROM users WHERE username = '$username'"; $result = @mysql_query($query); if(!$result) {   trigger_error("<p>SQL ERROR:<br>".mysql_error()."<br>Query: $query</p>",                 E_USER_WARNING); } elseif(mysql_numrows($result) != 1) {   trigger_error("<p>DB ERROR: There were multiple matches on this User ID</p>",                 E_USER_WARNING); } else  // we got exactly one match on the User ID {    echo "<b><center>Database Output</center></b><br><br>";       // only 1 match, so we don't need a loop    $row = mysql_fetch_assoc($result);    extract($row, EXTR_PREFIX_ALL, "user");    mysql_close();       echo <<<END    <b>$user_first_name $user_last_name</b><br> Date of Birth: $user_DOB<br> <b>Address</b><br> Street Address: $user_Street_address<br> Other Mailing Information: $user_post_office_box<br> City: $user_city <br> Province: $user_province<br> Postal Code: $user_postal<br> Home Phone Number: $user_home_phone<br> Email Address: $user_email_address<br> <hr><br> END; } ?> </body> [/code]
  17. And I continue to drag this on, I made the change and Tried it with no luck, I reviewed the code trying to find any other issues, but my rookyness provales and I cannot figure out what is wrong
  18. Thank you wisewood for the help. I'm probley making this more complicated then needed but any way The first post to made I need this echo "$_SESSION[username]"; to call the value assigned to the username. Am I correct in assuming that the value of username should have displayed on the page. If so nothing displayed which leads me to believe I have an error in the code that sets the session value thank you once again
  19. Orio Are you sugesting that I put the "session_start();" at the very top and put within its own php tags. wisewood I made the change but for some reason its to dispaying anything. I believe that the php code is scripted correctly as the page title displays on my web brozer page tab thank you for the help if I wanted to assign the session value to a variable would I do it this way $username = $_SESSION[username];
  20. Hi I used the tutorial from this web site to create a membership. I trying to you a value that was set using session s on page one and call it on page 2, I'm having no luck making this work Code to set the sessions Note "echo($username);" (bold in second part of code) calls the username name to login to my database ?????? [code] <html> <head> <title>Secure Login Page</title> </head> <body> <? /* Check User Script */ session_start();  // Start Session include 'dp.php'; // Conver to simple variables $username = $_POST['username']; $password = $_POST['password']; if((!$username) || (!$password)){     echo "Please enter ALL of the information! <br />";     include 'login.php';     exit(); } // Convert password to md5 hash $password = md5($password); // check if the user info validates the db $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){     while($row = mysql_fetch_array($sql)){     foreach( $row AS $key => $val ){         $$key = stripslashes( $val );     }         // Register some session variables!                  $_SESSION['first_name'] = $first_name;                  $_SESSION['last_name'] = $last_name;                  $_SESSION['email_address'] = $email_address;                $_SESSION['user_level'] = $user_level;                  $_SESSION['username'] = $username;                  mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");                  header("Location: login_success.php");     } [/code] code calling the sessions [code] <html> <head> <title>Get My Info</title> </head> <body> <? session_start(); include 'db.php'; [b] echo($username);[/b] // note, if userid is not a numeric type column, then $userid must be quoted $query = "SELECT * FROM users WHERE username = '$username'"; $result = @mysql_query($query); if(!$result) {   trigger_error("<p>SQL ERROR:<br>".mysql_error()."<br>Query: $query</p>",                 E_USER_WARNING); } elseif(mysql_numrows($result) != 1) {   trigger_error("<p>DB ERROR: There were multiple matches on this User ID</p>",                 E_USER_WARNING); } else  // we got exactly one match on the User ID {    echo "<b><center>Database Output</center></b><br><br>";       // only 1 match, so we don't need a loop    $row = mysql_fetch_assoc($result);    extract($row, EXTR_PREFIX_ALL, "user");    mysql_close();       echo <<<END    <b>$user_first_name $user_last_name</b><br> Date of Birth: $user_DOB<br> <b>Address</b><br> Street Address: $user_Street_address<br> Other Mailing Information: $user_post_office_box<br> City: $user_city <br> Province: $user_province<br> Postal Code: $user_postal<br> Home Phone Number: $user_home_phone<br> Email Address: $user_email_address<br> <hr><br> END; } ?> </body> [/code]
  21. Thank you for the relpy, I'm way to new at this and don't really undersand what you want me to do
  22. Thank you for the reply, I changed the summary page to post and nothing changed
  23. HI I have a form on my web page that has a link at the bottom which opens a summary page. my goal is to display the data from the form on the summary page. The code below somewhat works but when the link is clicked nothing displays on the summary page. when the button is clicked it cleares the data on the form, what to leave the data in the form fields. I believe the issue has something to do with the code on the summary page, as all the values are transfered to the adress bar when the submit button is clicked Any help is great thank you the below code it attached to the bottom of the form [code] // form code <form id="horizontalForm" name="ded" method="POST"> <input id="submit" type="submit" value="Calculate" onclick="compute(this.form)" /> //------------ <? echo "<a href='testpage.php?data=", serialize($_POST), "'>Summary</a>"; ?> [/code] code attached to the summary page [code] <? $data = $_Get["data"]; $values = unserialize($data); //$values has all the posted info from the previous page, in array form //$eiLastDate = $values["eiLastDate"]; //$values["y"] //etc... echo $values["eiLastDate"]; ?> [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.