newttster Posted January 27, 2011 Posted January 27, 2011 I am trying to get the "Simple Marriage" mod that Richard made to work but I am having problems with two things. The first is to get it to get the "Marital Status" to display below "Referals". ~~This is the code;~~ print "Marital Status: "; if ($r['marriage']) { $part=$db->query("SELECT * FROM users WHERE userid={$r['marriage']}"); $pr=$db->fetch_row($part); print "Married to {$pr['username']}"; } else { print "Single"; } print " "; And this is the code in viewuser.php where I am trying to get it to display underneath. Crystals: {$r['crystals']} Property: {$r['hNAME']} Referals: "; $rr=$db->query("SELECT * FROM referals WHERE refREFER={$r['userid']}"); print $db->num_rows($rr); print " And the second thing is an error message when I click on the link from the"Explore menu" Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/84/7099684/html/marriage.php:2) in /home/content/84/7099684/html/globals.php on line 6 Thank you for any help. Quote
SilvaTungDevil Posted January 27, 2011 Posted January 27, 2011 Do you have any error messages come up when you add that piece of code? Just so you know it should look like this: Crystals: {$r['crystals']} Property: {$r['hNAME']} Referals: "; $rr=$db->query("SELECT * FROM referals WHERE refREFER={$r['userid']}"); print $db->num_rows($rr); print " Marital Status: "; if ($r['marriage']) { $part=$db->query("SELECT * FROM users WHERE userid={$r['marriage']}"); $pr=$db->fetch_row($part); print "Married to [url='viewuser.php?u={$pr[']{$pr['username']}[/url]"; } else { print "Single"; } print " "; In regards to your second question, Have you included globals.php twice? Post up your marriage.php code here for us to see please Quote
newttster Posted January 27, 2011 Author Posted January 27, 2011 I inserted the code were you told me to SilvaTungDevil but now it is giving this error "Parse error: syntax error, unexpected ':' in /home/content/84/7099684/html/viewuser.php on line 107" I have included the code from line 90 - 116. Last Action: $str Last Login: $str2 Online: $on Days Old: {$r['daysold']} Location: {$r['cityname']}</td><td> Money: {$fm} Crystals: {$r['crystals']} Property: {$r['hNAME']} Referals: "; $rr=$db->query("SELECT * FROM referals WHERE refREFER={$r['userid']}"); print $db->num_rows($rr); print" Marital Status: "; if ($r['marriage']) { $part=$db->query("SELECT * FROM users WHERE userid={$r['marriage']}"); $pr=$db->fetch_row($part); print "Married to {$pr['username']}"; } else { print "Single"; } print " "; Friends: {$r['friend_count']} Enemies: {$r['enemy_count']} </td> <td>"; And here is the code from marriage.php ... Again the error message that I get is "Warning: session_start() [function. session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/84/7099684/html/marriage.php:2) in /home/content/84/7099684/html/globals.php on line 6" <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Marriage</font><hr width=75%>"; switch($_GET['action']) { case 'propose': propose_marriage(); break; case 'note': send_note(); break; case 'divorce': divorce_marriage(); break; case 'confirm': divorce_confirm(); break; case 'accept': accept_proposal(); break; case 'decline': decline_proposal(); break; default: marriage_index(); break; } function marriage_index() { global $ir,$c,$userid, $db; print "<center> Welcome to the marriage office! What would you like to do today? "; if (!$ir['marriage']) { print "> Propose marriage "; } else { print "> Divorce partner //> Send Bouquet of Roses ($10,000) > Send a love note "; } print " <hr width=75%>> Back<hr width=75%>"; } function propose_marriage() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); if(!$_POST['ID']) { print " <form action='marriage.php?action=propose' method='post'> Please type the ID# of the user you wish to propose to below. ID: <input type='text' name='ID' value='{$_GET['ID']}' maxlength='10' length='10' size='10' width='10' /> <input type='submit' value='Propose' /> </form> <hr width=75%>> Back<hr width=75%>"; } else if($ir['marriage']) { print " You are already married. <hr width=75%>> Back<hr width=75%>"; } else if($_POST['ID'] == $userid) { print " You cannot propose to yourself! <hr width=75%>> Back<hr width=75%>"; } else { $db->query("INSERT INTO proposals VALUES ('', '$userid', '{$_POST['ID']}')", $c); $q=$db->query("SELECT * FROM proposals WHERE prFROM=$userid"); $r=$db->fetch_row($q); event_add($_POST['ID'], "{$ir['username']} would like to marry you: Accept Decline", $c,'general'); print " Proposal sent! <hr width=75%>> Back<hr width=75%>"; } } function accept_proposal() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM proposals WHERE prID={$_GET['ID']}"); $r=$db->fetch_row($q); if(!$_GET['ID']) { print " Invalid proposal ID! <hr width=75%>> Back<hr width=75%>"; } else if($r['prUSER'] != $userid) { print " You cannot accept this proposal! <hr width=75%>> Back<hr width=75%>"; } else { $q=$db->query("SELECT * FROM proposals WHERE prUSER=$userid"); $r=$db->fetch_row($q); event_add($r['prFROM'], "{$ir['username']} has accepted your proposal!", $c); $db->query("UPDATE users SET marriage={$r['prFROM']} WHERE userid=$userid"); $db->query("UPDATE users SET marriage=$userid WHERE userid={$r['prFROM']}"); $db->query("DELETE FROM proposals WHERE prID={$_GET['ID']}"); print " Proposal accepted! <hr width=75%>> Back<hr width=75%>"; } } function decline_proposal() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM proposals WHERE prID={$_GET['ID']}"); $r=$db->fetch_row($q); if(!$_GET['ID']) { print " Invalid proposal ID! <hr width=75%>> Back<hr width=75%>"; } else if($r['prUSER'] != $userid) { print " You cannot decline this proposal! <hr width=75%>> Back<hr width=75%>"; } else { $q=$db->query("SELECT * FROM proposals WHERE prID={$_GET['ID']}"); $r=$db->fetch_row($q); event_add($r['prFROM'], "{$ir['username']} has declined your proposal.", $c); $db->query("DELETE FROM proposals WHERE prID={$_GET['ID']}"); print " Proposal declined! <hr width=75%>> Back<hr width=75%>"; } } function divorce_marriage() { global $db,$ir,$c,$userid,$h; if ($ir['marriage']) { print " Are you sure you wish to divorce your partner? <hr width=75%><table width=75%><tr><td width=50% align='center'>> No</td><td width=50% align='center'>> Yes</td></tr></table><hr width=75%>"; } else { print " You are not married! <hr width=75%>> Back<hr width=75%>"; } } function divorce_confirm() { global $db,$ir,$c,$userid,$h; if ($ir['marriage']) { print " You divorced your partner! <hr width=75%>> Back<hr width=75%>"; $db->query("UPDATE users SET marriage=0 WHERE userid={$ir['marriage']}"); $db->query("UPDATE users SET marriage=0 WHERE userid=$userid"); } else { print " You are not married! <hr width=75%>> Back<hr width=75%>"; } } function send_note() { global $db,$ir,$c,$userid,$h; if (!$_POST['note']) { print " <form action='marriage.php?action=note' method='post'> Please type a love note to send to your partner. Note: <textarea rows='5' cols='34%' name='note'></textarea> <input type='submit' value='Send' /> </form> <hr width=75%>> Back<hr width=75%>"; } else { $note=str_replace(array("\n"),array(" "),strip_tags($_POST['note'])); $db->query("INSERT INTO mail VALUES ('',0,$userid,{$ir['marriage']},unix_timestamp(),'Love Note','$note')",$c) or die($db->error()); $db->query("UPDATE users SET new_mail=new_mail+1 WHERE userid={$ir['marriage']}"); print " Your love note was sent to your partner! <hr width=75%>> Back<hr width=75%>"; } } $h->endpage(); ?> Quote
Aderik Posted January 27, 2011 Posted January 27, 2011 print " "; Friends: {$r['friend_count']} Enemies: {$r['enemy_count']} </td> <td>"; replace with print " Friends: {$r['friend_count']} Enemies: {$r['enemy_count']} </td> <td>"; Quote
newttster Posted January 27, 2011 Author Posted January 27, 2011 Thank you, Ade ... that worked perfectly. Now ... does anyone have any idea how I can fix the marriage.php one that I posted ... I am still getting that same error message. Quote
ILoveCP Posted January 27, 2011 Posted January 27, 2011 Hmm.. Try changing: include "globals.php"; // To this below require_once('globals.php'); Quote
newttster Posted January 27, 2011 Author Posted January 27, 2011 Thanks for the suggestion ILoveCP unfortunately I am still getting the same error message. Quote
Paul Evans Posted January 27, 2011 Posted January 27, 2011 $rr = $db->fetch_row($db->query("SELECT COUNT(`refREFER`) AS `r_CNT` FROM `referals` WHERE `refREFER` = '.$r['userid'])); print $rr['r_CNT']; Quote
newttster Posted January 28, 2011 Author Posted January 28, 2011 Paul ... thank you for that but the error message that I am getting is for the marriage.php file that is in Post 3. Quote
Paul Evans Posted January 28, 2011 Posted January 28, 2011 post your file in php tags and the error you're having. Quote
newttster Posted January 28, 2011 Author Posted January 28, 2011 <?php include "globals.php"; print "<center><font size='4' face='Arial, Helvetica, sans-serif'>Marriage</font><hr width=75%>"; switch($_GET['action']) { case 'propose': propose_marriage(); break; case 'note': send_note(); break; case 'divorce': divorce_marriage(); break; case 'confirm': divorce_confirm(); break; case 'accept': accept_proposal(); break; case 'decline': decline_proposal(); break; default: marriage_index(); break; } function marriage_index() { global $ir,$c,$userid, $db; print "<center> Welcome to the marriage office! What would you like to do today? "; if (!$ir['marriage']) { print "> [url='marriage.php?action=propose']Propose marriage[/url] "; } else { print "> [url='marriage.php?action=divorce']Divorce partner[/url] //> [url='marriage.php?action=roses']Send Bouquet of Roses ($10,000)[/url] > [url='marriage.php?action=note']Send a love note[/url] "; } print " <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } function propose_marriage() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); if(!$_POST['ID']) { print " <form action='marriage.php?action=propose' method='post'> Please type the ID# of the user you wish to propose to below. ID: <input type='text' name='ID' value='{$_GET['ID']}' maxlength='10' length='10' size='10' width='10' /> <input type='submit' value='Propose' /> </form> <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($ir['marriage']) { print " You are already married. <hr width=75%>> [url='trade.php']Back[/url]<hr width=75%>"; } else if($_POST['ID'] == $userid) { print " You cannot propose to yourself! <hr width=75%>> [url='marriage.php']Back[/url]<hr width=75%>"; } else { $db->query("INSERT INTO proposals VALUES ('', '$userid', '{$_POST['ID']}')", $c); $q=$db->query("SELECT * FROM proposals WHERE prFROM=$userid"); $r=$db->fetch_row($q); event_add($_POST['ID'], "{$ir['username']} would like to marry you: [url='marriage.php?action=accept&ID={$r[']Accept[/url] [url='marriage.php?action=decline&ID={$r[']Decline[/url]", $c,'general'); print " Proposal sent! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function accept_proposal() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM proposals WHERE prID={$_GET['ID']}"); $r=$db->fetch_row($q); if(!$_GET['ID']) { print " Invalid proposal ID! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['prUSER'] != $userid) { print " You cannot accept this proposal! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM proposals WHERE prUSER=$userid"); $r=$db->fetch_row($q); event_add($r['prFROM'], "{$ir['username']} has accepted your proposal!", $c); $db->query("UPDATE users SET marriage={$r['prFROM']} WHERE userid=$userid"); $db->query("UPDATE users SET marriage=$userid WHERE userid={$r['prFROM']}"); $db->query("DELETE FROM proposals WHERE prID={$_GET['ID']}"); print " Proposal accepted! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function decline_proposal() { global $db,$ir,$c,$userid,$h; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM proposals WHERE prID={$_GET['ID']}"); $r=$db->fetch_row($q); if(!$_GET['ID']) { print " Invalid proposal ID! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else if($r['prUSER'] != $userid) { print " You cannot decline this proposal! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $q=$db->query("SELECT * FROM proposals WHERE prID={$_GET['ID']}"); $r=$db->fetch_row($q); event_add($r['prFROM'], "{$ir['username']} has declined your proposal.", $c); $db->query("DELETE FROM proposals WHERE prID={$_GET['ID']}"); print " Proposal declined! <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } } function divorce_marriage() { global $db,$ir,$c,$userid,$h; if ($ir['marriage']) { print " Are you sure you wish to divorce your partner? <hr width=75%><table width=75%><tr><td width=50% align='center'>> [url='marriage.php']No[/url]</td><td width=50% align='center'>> [url='marriage.php?action=confirm']Yes[/url]</td></tr></table><hr width=75%>"; } else { print " You are not married! <hr width=75%>> [url='marriage.php']Back[/url]<hr width=75%>"; } } function divorce_confirm() { global $db,$ir,$c,$userid,$h; if ($ir['marriage']) { print " You divorced your partner! <hr width=75%>> [url='marriage.php']Back[/url]<hr width=75%>"; $db->query("UPDATE users SET marriage=0 WHERE userid={$ir['marriage']}"); $db->query("UPDATE users SET marriage=0 WHERE userid=$userid"); } else { print " You are not married! <hr width=75%>> [url='marriage.php']Back[/url]<hr width=75%>"; } } function send_note() { global $db,$ir,$c,$userid,$h; if (!$_POST['note']) { print " <form action='marriage.php?action=note' method='post'> Please type a love note to send to your partner. Note: <textarea rows='5' cols='34%' name='note'></textarea> <input type='submit' value='Send' /> </form> <hr width=75%>> [url='explore.php']Back[/url]<hr width=75%>"; } else { $note=str_replace(array("\n"),array(" "),strip_tags($_POST['note'])); $db->query("INSERT INTO mail VALUES ('',0,$userid,{$ir['marriage']},unix_timestamp(),'Love Note','$note')",$c) or die($db->error()); $db->query("UPDATE users SET new_mail=new_mail+1 WHERE userid={$ir['marriage']}"); print " Your love note was sent to your partner! <hr width=75%>> [url='marriage.php']Back[/url]<hr width=75%>"; } } $h->endpage(); ?> And this is the error message I get:"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/84/7099684/html/marriage.php:2) in /home/content/84/7099684/html/globals.php on line 6" I tried the require_once that ILovecp suggested and I still recieved the same error message. Quote
newttster Posted January 28, 2011 Author Posted January 28, 2011 Yes it does. As I add each new mod ... I check to make sure that I'm not getting any error messages. Could it be that I might have to add something to another file? Quote
lucky3809 Posted January 30, 2011 Posted January 30, 2011 You are probably missing the part for your header.php such as an if statement ... if($ir['married']){ $do_1 = mysql_query("SELECT * FROM users WHERE userid={$ir['married']}"); $r = $db->fetch_row($do_1); goes above this coding part in header... $enperc=(int) ($ir['energy']/$ir['maxenergy']*100); $wiperc=(int) ($ir['will']/$ir['maxwill']*100); $experc=(int) ( $ir['exp']/$ir['exp_needed']*100); $brperc=(int) ($ir['brave']/$ir['maxbrave']*100); $hpperc=(int) ($ir['hp']/$ir['maxhp']*100); Edit: Checked your file you posted NOTHING is wrong with it, I got NO errors. Quote
lucky3809 Posted January 30, 2011 Posted January 30, 2011 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/84/7099684/html/marriage.php:2) in /home/content/84/7099684/html/globals.php on line 6 you have a line that is in both php marriage and globals you need to delete one of them, both cant be declared look at line 6 in globals that should tell you or post that line on here and someone can tell you. but seems like your session_start function is being redeclared. Quote
newttster Posted January 31, 2011 Author Posted January 31, 2011 I want to thank everyone for your help with this ... I finally got it to work. I'm not sure why this made a difference ... but it did. On lines 34 and 38 I removed the ~>~ after the first quote mark and now it is working great. Thanks for all of your suggestions and ideas. Quote
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.