twilitegxa
-
Posts
1,020 -
Joined
-
Last visited
Posts posted by twilitegxa
-
-
On the same page I already have this:
//verify the scout exists $verify_scout = "select identity from scouts where id = $_GET[id]"; $verify_scout_res = mysql_query($verify_scout, $conn) or die(mysql_error()); if (mysql_num_rows($verify_scout_res) < 1) { //this character does not exist $display_block = "<p><em>You have selected an invalid character. Please <a href=\"existing.php\">try again</a></em></p>"; } else { //gather rest of profile fields $get_scout = "select * from scouts where id = $_GET[id]"; $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error()); while ($scout_info = mysql_fetch_array($get_scout_res)) { $scout_id = $scout_info['id']; $identity = ucwords($scout_info['identity']); $accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE id = '$scout_id'"); $accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE id = '$scout_id'"); } }
Could I not get the id from there?
-
Does anyone know how I can get the id in this meta tag?
<META http-equiv="refresh" content="5;URL=showprofile_scouts.php?id=$topic_id">
This isn't working. It's saying that $topic_id is an unknown column in the where clause.
Can anyone help?
-
Okay, I will try working with it. Thanks.
-
I'm having some trouble getting it to redirect to the correct page. I want it to redirect to the profile of the character that they just accepted. I am guessing I would have to use the id, but I am for some reason not getting it right. Can I even use the meta refresh for this? Or do I need to use the PHP header?
-
How can I redirect the user to the character's profile page after so many seconds (say 5 seconds), after they have accepted the character as their own? They reach the following page after accepting the character:
<?php session_start(); //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("smrpg", $conn) or die(mysql_error()); //verify the scout exists $verify_scout = "select identity from scouts where id = $_GET[id]"; $verify_scout_res = mysql_query($verify_scout, $conn) or die(mysql_error()); if (mysql_num_rows($verify_scout_res) < 1) { //this character does not exist $display_block = "<p><em>You have selected an invalid character. Please <a href=\"existing.php\">try again</a></em></p>"; } else { //gather rest of profile fields $get_scout = "select * from scouts where id = $_GET[id]"; $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error()); while ($scout_info = mysql_fetch_array($get_scout_res)) { $scout_id = $scout_info['id']; $identity = ucwords($scout_info['identity']); $accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE id = '$scout_id'"); $accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE id = '$scout_id'"); } } ?> <html> <head> <title>You Have Accepted Character: <?php print $identity; ?></title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <!-- HEADER --> <h1 class="logo">Sailor Moon RPG</h1> <!-- /HEADER --> <?php include("topnav.php"); ?> <div id="main"> <?php include("includes/log.php"); ?> <?php include("mainnav.php"); ?> <h1 align="center"><?php print $identity; ?>: Accepted</h1> <h3>You have accepted the existing character, <strong><?php print $identity; ?></strong>.</h3> </div> <?php include("bottomnav.php"); ?><!-- FOOTER --> <!-- FOOTER --> <div id="footer_wrapper"> <div id="footer"> <p>Sailor Moon and all characters are<br /> trademarks of Naoko Takeuchi.</p> <p>Copyright © 2009 Liz Kula. All rights reserved.<br /> A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p> <div id="foot-nav"> <ul> <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li> <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li> </ul> </div> </div> </div> <!-- /FOOTER --> </body> </html>
And I have used the following script to get the profile before (this displays the identity, and then leads to that character's profile:
//show scouts characters $get_scouts = "select * from scouts where username = '".$_SESSION['userName']."'"; $get_scouts_res = mysql_query($get_scouts, $conn) or die(mysql_error()); while ($list_scouts = mysql_fetch_array($get_scouts_res)) { $identity = ucwords($list_scouts['identity']); $topic_id = $list_scouts['id']; echo "<ul class=\"character_list\"><li><a href=\"showprofile_scouts.php?id=$topic_id\">$identity</li></ul> "; }
-
Thanks. I will look into JQuery. :-)
-
I think I have tried this before, but it showed the scroll each time. What I would like to do is when the page refreshes, for it not to scroll back up to the top, but stay wherever the user has it. Say the user is scrolling down to read something another user typed previously. Every time the page refreshes, the page scrolls back up to the top and the user cannot read what they are trying to read. Does this make sense? Does anyone know if what I'm trying to do is possible?
-
Is there a way to stop the page from scrolling to the top on refresh? Here is my chatroom:
chatlog.php
<html> <head> <title></title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <?php include "connect.php"; $getnummessages="SELECT COUNT(*) as messagecount from chatmessages"; $getnummessages2=mysql_query($getnummessages) or die("blah"); $getnummessages3= mysql_result($getnummessages2, 0); if($getnummessages3>10000000) { $startrow=$getmessages3-20; } else { $startrow=0; } $getmsg="SELECT name, message from chatmessages order by postime DESC limit $startrow,$getnummessages3"; $getmsg2=mysql_query($getmsg) or die(mysql_error()); while($getmsg3=mysql_fetch_array($getmsg2)) { $message=' '; $message=Smiley($message); //Smiley faces $getmsg3['message'] = nl2br($getmsg3['message']); //includes line breaks in messages $getmsg3['message'] = wordwrap($getmsg3['message'],170,'<br />',true); print "<font color='teal'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>"; } function Smiley($texttoreplace) { $smilies=array( '' => "<img src='images/smile.gif'>", ':blush' =>"<img src='images/blush.gif'>", ':angry' =>"<img src='images/angry.gif'>", ''=> "<img src='images/shocked.gif'>", 'fuck'=>"$#$%", 'Fuck'=>"&$#@" ); $texttoreplace=str_replace(array_keys($smilies), array_values($smilies), $texttoreplace); return $texttoreplace; } ?> <script> setTimeout("window.location.replace('chatlog.php')",1000); </script> </body> </html>
submit
<?php session_start(); ?> <html> <head> <title></title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <?php include "connect.php"; if(isset($_POST['submit'])) //if submit button push has been detected { $message= nl2br($_POST['message']); $name=$_SESSION['userName']; if(strlen($message)<1) { print "You did not input a message"; } else if(strlen($name)<1) { print "You are not logged in. Please log in."; } else { $message=strip_tags($message); $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP $checkforbanned="SELECT IP from ipbans where IP='$IP'"; $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS"); if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list { print "Your IP is banned from posting. Please contact administration."; } else { $thedate = date("U"); //grab date and time of the post $insertmessage="INSERT into chatmessages (name,IP,postime,message) values('$name','$IP','$thedate','$message')"; mysql_query($insertmessage) or die("Could not insert message"); } } } print "<form action='submit.php' method='post' name='form'>"; //print "<strong>Your name:</strong><br>"; not needed //print "<input type='text' name='name' size='20'><br>"; not needed print "<strong>Your message:</strong><br>"; print "<textarea name='message' cols='40' rows='4'></textarea><br>"; print "<a onClick=\"addSmiley('')\"><img src='images/smile.gif'></a> "; //replace images/smile.gif with the relative path of your smiley print "<a onClick=\"addSmiley('')\"><img src='images/sad.gif'></a> "; print "<a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='submit'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(textToAdd)\n"; print "{\n"; print "document.form.message.value += textToAdd;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; ?> </body> </html>
chatframe
<?php session_start(); if(!isset($_SESSION['loggedIn'])) { header("Location: login.php"); } ?> <html> <head> <title>Sailor Moon RPG - Battle Chat</title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <!-- HEADER --> <h1 class="logo">Sailor Moon RPG</h1> <!-- /HEADER --> <?php include("topnav.php"); ?> <div id="main"> <?php include("includes/log.php"); ?> <?php include("mainnav.php"); ?> <h1>Sailor Moon RPG - Battle Chat</h1> <?php print "<table width=80%><tr><td><iframe src='chatlog.php' name='chatlogframe' width='80%' height='400'></iframe></td></tr>"; print "<tr><td><iframe src='submit.php' width='80%' height='250' frameborder='0' class='message'></iframe></td></tr></table>"; ?> </div> <?php include("bottomnav.php"); ?><!-- FOOTER --> <!-- FOOTER --> <div id="footer_wrapper"> <div id="footer"> <p>Sailor Moon and all characters are<br /> trademarks of Naoko Takeuchi.</p> <p>Copyright © 2009 Liz Kula. All rights reserved.<br /> A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p> <div id="foot-nav"> <ul> <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li> <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li> </ul> </div> </div> </div> <!-- /FOOTER --> </body> </html>
Is this possible?
-
Thank you for showing me how to write it. Now I think I better understand it. Thank you so much!
-
I'm sorry. This link does help, but I just don't understand how to write it. I tried:
$getmsg3['message'] = wordwrap($getmsg3['message']);
But I don't understand how to set the other parameters. Can you please help me a little more?
-
I have the following scripts:
chatlog.php
<html> <head> <title></title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <?php include "connect.php"; $getnummessages="SELECT COUNT(*) as messagecount from chatmessages"; $getnummessages2=mysql_query($getnummessages) or die("blah"); $getnummessages3= mysql_result($getnummessages2, 0); if($getnummessages3>10000000) { $startrow=$getmessages3-20; } else { $startrow=0; } $getmsg="SELECT name, message from chatmessages order by postime DESC limit $startrow,$getnummessages3"; $getmsg2=mysql_query($getmsg) or die(mysql_error()); while($getmsg3=mysql_fetch_array($getmsg2)) { $message=' '; $message=Smiley($message); //Smiley faces print "<font color='teal'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>"; } function Smiley($texttoreplace) { $smilies=array( '' => "<img src='images/smile.gif'>", ':blush' =>"<img src='images/blush.gif'>", ':angry' =>"<img src='images/angry.gif'>", ''=> "<img src='images/shocked.gif'>", 'fuck'=>"$#$%", 'Fuck'=>"&$#@" ); $texttoreplace=str_replace(array_keys($smilies), array_values($smilies), $texttoreplace); return $texttoreplace; } ?> <script> setTimeout("window.location.replace('chatlog.php')",1000); </script> </body> </html>
submit.php
<?php session_start(); ?> <html> <head> <title></title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <?php include "connect.php"; if(isset($_POST['submit'])) //if submit button push has been detected { $message= nl2br($_POST['message']); $name=$_SESSION['userName']; if(strlen($message)<1) { print "You did not input a message"; } else if(strlen($name)<1) { print "You are not logged in. Please log in."; } else { $message=strip_tags($message); $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP $checkforbanned="SELECT IP from ipbans where IP='$IP'"; $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS"); if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list { print "Your IP is banned from posting. Please contact administration."; } else { $thedate = date("U"); //grab date and time of the post $insertmessage="INSERT into chatmessages (name,IP,postime,message) values('$name','$IP','$thedate','$message')"; mysql_query($insertmessage) or die("Could not insert message"); } } } print "<form action='submit.php' method='post' name='form'>"; //print "<strong>Your name:</strong><br>"; not needed //print "<input type='text' name='name' size='20'><br>"; not needed print "<strong>Your message:</strong><br>"; print "<textarea name='message' cols='40' rows='4'></textarea><br>"; print "<a onClick=\"addSmiley('')\"><img src='images/smile.gif'></a> "; //replace images/smile.gif with the relative path of your smiley print "<a onClick=\"addSmiley('')\"><img src='images/sad.gif'></a> "; print "<a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='submit'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(textToAdd)\n"; print "{\n"; print "document.form.message.value += textToAdd;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; ?> </body> </html>
chatframe.php
<?php session_start(); if(!isset($_SESSION['loggedIn'])) { header("Location: login.php"); } ?> <html> <head> <title>Sailor Moon RPG - Battle Chat</title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <!-- HEADER --> <h1 class="logo">Sailor Moon RPG</h1> <!-- /HEADER --> <?php include("topnav.php"); ?> <div id="main"> <?php include("includes/log.php"); ?> <?php include("mainnav.php"); ?> <h1>Sailor Moon RPG - Battle Chat</h1> <?php print "<table width=80%><tr><td><iframe src='chatlog.php' name='chatlogframe' width='80%' height='400'></iframe></td></tr>"; print "<tr><td><iframe src='submit.php' width='80%' height='250' frameborder='0' class='message'></iframe></td></tr></table>"; ?> </div> <?php include("bottomnav.php"); ?><!-- FOOTER --> <!-- FOOTER --> <div id="footer_wrapper"> <div id="footer"> <p>Sailor Moon and all characters are<br /> trademarks of Naoko Takeuchi.</p> <p>Copyright © 2009 Liz Kula. All rights reserved.<br /> A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p> <div id="foot-nav"> <ul> <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li> <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li> </ul> </div> </div> </div> <!-- /FOOTER --> </body> </html>
How can I make the chatlog page wrap? Right now, if a user types a long line of text, it keeps going horizontally. I want it to wrap to the next line. How do I do this?
-
I have the following script:
<?php session_start(); ?> <form> <table cellpadding="3" cellspacing="3"> <tr> <th>Attribute</th> <th>Level</th> <th>Power Points:</th> <th>Character Points:</th> </tr> <tr> <td><input type="text" readonly="readonly" value="Scout/Knight Powers" size="19" name="attribute1" /></td> <td><select name="level" onclick="power(), remain()"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> </select></td> <td align="center"><input type="text" name="power_points" id="power_points" size="1" readonly="readonly"/></td> <td align="center"><input type="text" name="cp_remain" id="cp_remain" size="1" readonly="readonly" /></td> </tr> </table> </form> <form method="POST" action="test_batosai.php"> <table><tr><td> <div id="dynamicInput1"> <table cellpadding="3" cellspacing="3"> <thead> <tr> <th>Sub-Attribute</th> <th>Level</th> <th>Notes <i>(optional)</i></th> </tr> </thead> <tbody> <tr> <td> <select name="attribute[]" size="1"> <option value="1">Animal Guardian</option> <option value="2">Combined Attacks</option> <option value="3">Elemental Control</option> <option value="4">Emotional Control</option> <option value="5">Item Of Power</option> <option value="6">Knight Attack</option> <option value="7">Rejuvenation</option> <option value="8">Sailor Scout Attack</option> </select></td> <td> <select name="attribute_level[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> </select></td> <td><textarea name="sub_notes[]" rows="1" cols="30"> </textarea></td> </tr> </tbody> </table> </div> <div id="cloneDiv1"> </div> </td> <td> <div id="dynamicInput2"> <table cellpadding="3" cellspacing="3"> <thead> <tr> <th>Neutral Attribute</th> <th>Level</th> <th>Notes <i>(optional)</i></th> </tr> </thead> <tbody> <tr> <td> <select name="attribute2[]" size="1"> <option value="1">Acrobatics</option> <option value="2">Appearance</option> <option value="3">Art Of Distraction</option> <option value="4">Combat Mastery</option> <option value="5">Damn Healthy!</option> <option value="6">Divine Relationship</option> <option value="7">Energy Bonus</option> <option value="8">Extra Attacks</option> <option value="9">Focused Combat</option> <option value="10">Fortified Body</option> <option value="11">Heightened Negaverse Power</option> <option value="12">Heightened Senses</option> <option value="13">Heightened Scout Powers</option> <option value="14">Massive Damage</option> <option value="15">Powerful Mind</option> <option value="16">Special Attack/Defense</option> <option value="17">Speed</option> <option value="18">Strong Soul</option> <option value="19">Supernatural Training</option> <option value="20">Unique Character Attribute</option> </select></td> <td> <select name="attribute_level2[]"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> </select></td> <td><textarea name="neutral_notes[]" rows="1" cols="30"> </textarea></td> </tr> </tbody> </table> </div> <div id="cloneDiv2"> </div> </td></tr></table> <input type="button" value="Add another Sub-Attribute" onClick="addInput('dynamicInput1','cloneDiv1');"> <input type="button" value="Add another Neutral Attribute" onClick="addInput('dynamicInput2','cloneDiv2');"> <input type="submit" /><input type="reset" /> </form> <script type="text/javascript"> var counter = 1; var limit = 10000000;// Set a limit if you want to function addInput(divFrom,divTo){ if (counter == limit) { alert("You have reached the limit of adding " + counter + " inputs"); } else { var newdiv = document.createElement('div'); newdiv.innerHTML = document.getElementById(divFrom).innerHTML; document.getElementById(divTo).appendChild(newdiv); counter++; } } //function for Power Points function power() { var first,res1; //Take the value of first textbox and convert it to float first=parseFloat(document.forms[0].level.value); res1=(first)*10; //show the result in the result textbox document.forms[0].power_points.value=res1; } //end function for Power Points //function for Character Points remaining function remain() { var first,res2; //Take the value of first textbox and convert it to float first=parseFloat(document.forms[0].level.value); res2=10-((first)*4); //show the result in the result textbox document.forms[0].cp_remain.value=res2; } //end function for Character Points </script>
How can I write a JavaScript that will update the power_points field if the sub-attribute is chosen? Like:
if animal guardian is chosen
Power_points - (attribute_level * 1)
if combined attacks is chosen
power_points - (attribute_level * 1)
if elemental control is chosen
power_points - (attribute_level * 3)
etc...
Can anyone help?
-
I changed this on my display page:
//verify the scout exists $verify_scout = "select identity from scouts where id = $_GET[id]"; $verify_scout_res = mysql_query($verify_scout, $conn) or die(mysql_error()); if (mysql_num_rows($verify_scout_res) < 1) { //this character does not exist $display_block = "<p><em>You have selected an invalid character. Please <a href=\"existing.php\">try again</a></em></p>"; } else { //gather rest of profile fields $get_scout = "select * from scouts where id = $_GET[id]"; $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error()); while ($scout_info = mysql_fetch_array($get_scout_res)) { $scout_id = $scout_info['id']; $identity = ucwords($scout_info['identity']); $display_block .= "<table width=100%> <tr> <td align=center> <h3>Would you like to use this character?</h3> <a href=accept_character.php?id=$scout_id><input type=button value=Yes /></a> <a href=existing.php><input type=button value=No /></a> </td> </tr> </table>"; } }
and on the update page:
<?php session_start(); //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("smrpg", $conn) or die(mysql_error()); //verify the scout exists $verify_scout = "select identity from scouts where id = $_GET[id]"; $verify_scout_res = mysql_query($verify_scout, $conn) or die(mysql_error()); if (mysql_num_rows($verify_scout_res) < 1) { //this character does not exist $display_block = "<p><em>You have selected an invalid character. Please <a href=\"existing.php\">try again</a></em></p>"; } else { //gather rest of profile fields $get_scout = "select * from scouts where id = $_GET[id]"; $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error()); while ($scout_info = mysql_fetch_array($get_scout_res)) { $scout_id = $scout_info['id']; $identity = ucwords($scout_info['identity']); $accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE id = '$scout_id'"); $accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE id = '$scout_id'"); } } ?> <html> <head> <title>You Have Accepted Character: <?php print $identity; ?></title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <!-- HEADER --> <h1 class="logo">Sailor Moon RPG</h1> <!-- /HEADER --> <?php include("topnav.php"); ?> <div id="main"> <?php include("includes/log.php"); ?> <?php include("mainnav.php"); ?> <h1 align="center"><?php print $identity; ?>: Accepted</h1> <h3>You have accepted the existing character, <strong><?php print $identity; ?></strong>.</h3> </div> <?php include("bottomnav.php"); ?><!-- FOOTER --> <!-- FOOTER --> <div id="footer_wrapper"> <div id="footer"> <p>Sailor Moon and all characters are<br /> trademarks of Naoko Takeuchi.</p> <p>Copyright © 2009 Liz Kula. All rights reserved.<br /> A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p> <div id="foot-nav"> <ul> <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li> <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li> </ul> </div> </div> </div> <!-- /FOOTER --> </body> </html>
Thanks for your help! What you e-mailed me helped!
-
How can I put this update statement on the profile page so that when they click the Yes button, it updates and prints a message saying they have accepted the character? If I put the update statement on the page, it seems to shwo the right identity. I tried to do it like this:
<h3>Would you like to use this character?</h3>
<a href="<?php
$query = "UPDATE scouts SET username='".$_SESSION['userName']."', available=0 WHERE identity = '".$identity."'";
echo $query; // check to make sure it's what you want the query to be
$result = mysql_query($query);
?>"><input type="button" value="Yes" /></a>
<a href="existing.php"><input type="button" value="No" /></a>
But of course it didn't work because the php statement is not a url to link to. But it did display the right information:
The requested URL /UPDATE scouts SET username='twilitegxa', available=0 WHERE identity = 'Sailor Jupiter' was not found on this server.
Would I do this with an if statement? Like if yes is click, update. If no is clicked, go to exisiting.php? How can i write this statement?
-
I don't understand what you mean, darkfreaks.
That $verify_topics statement is displaying the right information from the scouts table on the display page. The problem I'm having is when I try to update the two fields in the record from the scouts table, the identity is always the last record inserted into the table. I want to update the record of the identity of the page I am viewing when I click the button that takes the user to the update page. But for some reason the identity is showing as the last record inserted instead of the identity of the page that was being viewed right before pressing the button to update the record.
-
How do I do that? When I display the identity on the profile page, I get it here:
//verify the topic exists
$verify_topic = "select identity from scouts where
id = $_GET[id]";
$verify_topic_res = mysql_query($verify_topic, $conn)
or die(mysql_error());
if (mysql_num_rows($verify_topic_res) < 1) {
//this character does not exist
$display_block = "<p><em>You have selected an invalid character.
Please <a href="listcharacters.php">try again</a></em></p>";
} else {
//gather rest of profile
$get_posts = "select *, date_format(create_time, '%b %e %Y at %r') as fmt_scout_create_time from scouts where id = $_GET[id]";
$get_posts_res = mysql_query($get_posts, $conn) or die(mysql_error());
//create the display string
$display_block = "
<table cellpadding=3 cellspacing=1 border=0 class=list_tables>";
while ($posts_info = mysql_fetch_array($get_posts_res)) {
$post_id = $posts_info['id'];
$identity = ucwords($posts_info['identity']);
It displays right when I choose an identity from the page that displays all identities, but to get the identity on this page I am using select identity from scouts where
id = $_GET[id]";
Do I need to use $_GET[id]?
-
It appears to be only updating the last record inserted.
-
I added all my code in case I was doing anythign wrong LOL
And I forgot that I was still using the $_SESSION[identity] LOL
But, it still isn't working. The values are being updated, but still only that that one specific record, not the one that was displayed:
UPDATE scouts SET username='kainan', available=0 WHERE identity = 'Sailor Trinity'
I was accessing Sailor Jupiter, but it always updates Sailor Trinity for some reason.
-
Rest of the display page:
$get_sub_attributes = "select * from scout_sub_attributes where identity = '$identity'"; $get_sub_attributes_res = mysql_query($get_sub_attributes, $conn) or die(mysql_error()); while ($sub_attributes_info = mysql_fetch_array($get_sub_attributes_res)) { $sub_attributes_id = $sub_attributes_info['id']; $sub_attributes_identity = $sub_attributes_info['identity']; $sub_attributes_attribute_id = $sub_attributes_info['sub_attribute_id']; $sub_attributes_level_id = $sub_attributes_info['level_id']; $sub_attributes_notes = $sub_attributes_info['notes']; $get_sub_attribute_names = "select * from sub_attributes where id = '$sub_attributes_attribute_id'"; $get_sub_attribute_names_res = mysql_query($get_sub_attribute_names, $conn) or die(mysql_error()); while ($sub_attribute_names_info = mysql_fetch_array($get_sub_attribute_names_res)) { $sub_attribute_names_id = $sub_attribute_names_info['id']; $sub_attribute_names_attribute = $sub_attribute_names_info['sub_attribute']; $sub_attribute_names_points = $sub_attribute_names_info['points']; $sub_attributes_points = ($sub_attribute_names_points * $sub_attributes_level_id); $display_block .= " <tr> <td class=indent>$sub_attribute_names_attribute</td>"; if ($sub_attributes_level_id == null) { $display_block .= "<td> </td> <td> </td></tr>"; } else { $display_block .= " <td class=align_levels>$sub_attributes_level_id</td> <td class=align_levels>$sub_attributes_points</td></tr>"; } //gather attacks $get_items = "select * from items where identity = '$identity' and acquired = 1 order by level asc"; $get_items_res = mysql_query($get_items, $conn) or die(mysql_error()); while ($items_info = mysql_fetch_array($get_items_res)) { $item_id = $items_info['id']; $item_identity = $items_info['identity']; $items = $items_info['item']; $item_desc = $items_info['desc']; $item_level = $items_info['level']; $item_points = ($sub_attribute_names_points * $item_level); if ($sub_attribute_names_attribute == 'Item Of Power') { $display_block .= " <tr> <td class=indent2>- $items</td> <td class=align_levels>$item_level</td> <td class=align_levels>$item_points</td> </tr> <tr>"; } } } } //gather attacks $get_attacks = "select * from attacks where identity = '$identity' and level <= '$character_attack_level' and learned = 1 order by level desc"; $get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error()); while ($attacks_info = mysql_fetch_array($get_attacks_res)) { $attack_id = $attacks_info['id']; $attack_identity = $attacks_info['identity']; $attack = $attacks_info['attack']; $primary = $attacks_info['primary_attack']; $secondary = $attacks_info['secondary_attack']; $attack_level = $attacks_info['level']; $attack_points = ($sub_attribute_names_points * $attack_level); $learned = $attacks_info['learned']; //checks for primary and secondary attacks if($secondary == 1) $attack_points = 2; elseif($primary == 0 && $secondary == 0) $attack_points = 1; if ($sub_attribute_names_attribute == 'Sailor Scout Attack') { $display_block .= " <tr> <td class=indent2>- $attack</td> <td class=align_levels>$attack_level</td> <td class=align_levels>$attack_points</td> </tr> <tr>"; } } //gather neutral attributes $get_neutral_attributes = "select * from scout_neutral_attributes where identity = '$identity'"; $get_neutral_attributes_res = mysql_query($get_neutral_attributes, $conn) or die(mysql_error()); while ($neutral_attributes_info = mysql_fetch_array($get_neutral_attributes_res)) { $neutral_attributes_id = $neutral_attributes_info['id']; $neutral_attributes_identity = $neutral_attributes_info['identity']; $neutral_attributes_attribute_id = $neutral_attributes_info['attribute_id']; $neutral_attributes_level_id = $neutral_attributes_info['level_id']; $get_neutral_attribute_names = "select * from neutral_attributes where id = '$neutral_attributes_attribute_id'"; $get_neutral_attribute_names_res = mysql_query($get_neutral_attribute_names, $conn) or die(mysql_error()); while ($neutral_attribute_names_info = mysql_fetch_array($get_neutral_attribute_names_res)) { $neutral_attribute_names_id = $neutral_attribute_names_info['id']; $neutral_attribute_names_attribute = $neutral_attribute_names_info['attribute']; $neutral_attribute_names_points = $neutral_attribute_names_info['points']; $neutral_attribute_points = ($neutral_attributes_level_id * $neutral_attribute_names_points); $display_block .= " <tr> <td>$neutral_attribute_names_attribute</td> <td class=align_levels>$neutral_attributes_level_id</td> <td class=align_levels>$neutral_attribute_points</td> </tr>"; } } $display_block .= " </table></td></tr></table><br>"; $display_block .= " <table border=0 width=100%> <tr> <td width=50% valign=top> <table> <tr> <td align=center><h1>Items Of Power</h1></td>"; $get_items = "select * from items where identity = '$identity' and acquired = 1"; $get_items_res = mysql_query($get_items, $conn) or die(mysql_error()); while ($items_info = mysql_fetch_array($get_items_res)) { $items_id = $items_info['id']; $items_identity = $items_info['identity']; $item = $items_info['item']; $item_desc = nl2br($items_info['desc']); $item_level = $items_info['level']; $item_points = ($sub_attribute_names_points * $item_level); $display_block .= " <tr> <td class=hanging-indent> <i>$item --- </i><br> $item_desc</td></tr>"; } $display_block .= "</table></td><td valign=top width=50%> <table> <tr> <td align=center><h1>Sailor Scout Attacks</td></tr>"; //gather attacks $get_attacks = "select * from attacks where identity = '$identity' and learned = 1 order by level asc"; $get_attacks_res = mysql_query($get_attacks, $conn) or die(mysql_error()); while ($attacks_info = mysql_fetch_array($get_attacks_res)) { $attack_id = $attacks_info['id']; $attack_identity = $attacks_info['identity']; $attack = $attacks_info['attack']; $attack_desc = nl2br($attacks_info['desc']); $primary = $attacks_info['primary_attack']; $secondary = $attacks_info['secondary_attack']; $attack_level = $attacks_info['level']; $attack_points = ($sub_attribute_names_points * $attack_level); $display_block .= " <tr> <td class=hanging-indent> <i>$attack --- </i><br> $attack_desc</td></tr>"; } $display_block .= "</table></td></tr></table>"; $display_block .= "<table border=0 cellpadding=3 cellspacing=3 width=100%> <tr> <td width=50% valign=top> <table> <tr> <td align=center><h1>Transformations</h1></td> </tr>"; $get_transformations = "select * from transformations where identity = '$identity'"; $get_transformations_res = mysql_query($get_transformations, $conn) or die(mysql_error()); while ($transformation_info = mysql_fetch_array($get_transformations_res)) { $transformation_id = $transformation_info['id']; $transformation_identity = $transformation_info['identity']; $transformation = $transformation_info['transformation']; $transformation_desc = $transformation_info['desc']; $transformation_level = $transformation_info['level']; $display_block .= " <tr> <td class=hanging-indent> <i>$transformation --- </i><br> $transformation_desc</td></tr>"; } $display_block .= "</table></td> <td width=50% valign=top> <table> <tr> <td align=center><h1>Attribute/Sub-Attribute Notes</h1></td></tr> <tr> <td> <ol>"; //gather attributes and sub-attributes notes $get_sub_notes = "select * from scout_sub_attributes where identity = '$identity' and notes IS NOT NULL"; $get_sub_notes_res = mysql_query($get_sub_notes, $conn) or die(mysql_error()); while ($sub_notes_info = mysql_fetch_array($get_sub_notes_res)) { $sub_notes = nl2br($sub_notes_info['notes']); $sub_id = $sub_notes_info['sub_attribute_id']; $display_block.= " <li>$sub_notes</li>"; } //gather neutral notes $get_neutral_notes = "select notes from scout_neutral_attributes where identity = '$identity' and notes IS NOT NULL"; $get_neutral_notes_res = mysql_query($get_neutral_notes, $conn) or die(mysql_error()); while ($neutral_notes_info = mysql_fetch_array($get_neutral_notes_res)) { $neutral_notes = nl2br($neutral_notes_info['notes']); $display_block .= " <li>$neutral_notes</li>"; } //gather defect notes $get_defect_notes = "select notes from scout_defects where identity = '$identity' and notes IS NOT NULL"; $get_defect_notes_res = mysql_query($get_defect_notes, $conn) or die(mysql_error()); while ($defect_notes_info = mysql_fetch_array($get_defect_notes_res)) { $defect_notes = nl2br($defect_notes_info['notes']); $display_block .= " <li>$defect_notes</li>"; } $display_block .= "</ol></table></td></tr></table>"; ?> <html> <head> <title><?php print $identity; ?>'s Profile</title> <style type="text/css" media="screen"> /*<![CDATA[*/ @import url(global.css); /*]]>*/ </style> </head> <body> <!-- HEADER --> <h1 class="logo">Sailor Moon RPG</h1> <!-- /HEADER --> <?php include("topnav.php"); ?> <div id="main"> <?php include("includes/log.php"); ?> <?php include("mainnav.php"); ?> <h1 align="center"><?php print $identity; ?></h1> <?php print $display_block; ?> <table width="100%"> <tr> <td align="center"> <h3>Would you like to use this character?</h3> <a href="accept_character.php"><input type="button" value="Yes" /></a> <a href="existing.php"><input type="button" value="No" /></a> </td> </tr> </table> </div> <?php include("bottomnav.php"); ?><!-- FOOTER --> <!-- FOOTER --> <div id="footer_wrapper"> <div id="footer"> <p>Sailor Moon and all characters are<br /> trademarks of Naoko Takeuchi.</p> <p>Copyright © 2009 Liz Kula. All rights reserved.<br /> A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p> <div id="foot-nav"> <ul> <li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li> <li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li> </ul> </div> </div> </div> <!-- /FOOTER --> </body> </html>
It will only update the record of a specific character, but not the one being displayed. What could be causing this?
-
I am having some trouble still. My updating statement seems to work, but it will only update a specific record. It will not update the record of the character I am trying to update it for. How can I choose the identity of the character that is displayed on the page? Here is my update statement:
<?php session_start(); //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("smrpg", $conn) or die(mysql_error()); $identity = $_SESSION['identity']; $accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE identity = '$_SESSION[identity]'"); $accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE identity = '$_SESSION[identity]'"); ?>
And here is the page displaying the character's profile:
<?php session_start(); //Access Tracking Snippet //set up static variables $page_title = "showprofile.php"; $user_agent = getenv("HTTP_USER_AGENT"); $date_accessed = date("Y-m-d"); //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("smrpg", $conn) or die(mysql_error()); //create and issue query $sql = "insert into access_tracker values ('', '$page_title', '$user_agent', '$date_accessed')"; mysql_query($sql,$conn); ?> <?php //check for required info from the query string if (!$_GET['id']) { header("Location: listcharacters.php"); exit; } //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("smrpg", $conn) or die(mysql_error()); //verify the topic exists $verify_topic = "select identity from scouts where id = $_GET[id]"; $verify_topic_res = mysql_query($verify_topic, $conn) or die(mysql_error()); if (mysql_num_rows($verify_topic_res) < 1) { //this character does not exist $display_block = "<p><em>You have selected an invalid character. Please <a href=\"listcharacters.php\">try again</a></em></p>"; } else { //gather rest of profile $get_posts = "select *, date_format(create_time, '%b %e %Y at %r') as fmt_scout_create_time from scouts where id = $_GET[id]"; $get_posts_res = mysql_query($get_posts, $conn) or die(mysql_error()); //create the display string $display_block = " <table cellpadding=3 cellspacing=1 border=0 class=list_tables>"; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['id']; $identity = ucwords($posts_info['identity']); $character_create_time = $posts_info['fmt_scout_create_time']; $username = $posts_info['username']; $name = ucwords(strtolower($posts_info['name'])); $element_of_influence = $posts_info['element_of_influence']; $age = $posts_info['age']; $birth_month = $posts_info['birth_month']; $birth_date = $posts_info['birth_date']; $birth_year = $posts_info['birth_year']; $height_feet = $posts_info['height_feet']; $height_inches = $posts_info['height_inches']; $blood_type = strtoupper($posts_info['blood_type']); $hobbies = ucwords(strtolower($posts_info['hobbies'])); $favorite_color = ucwords(strtolower($posts_info['favorite_color'])); $favorite_gemstone = ucwords(strtolower($posts_info['favorite_gemstone'])); $favorite_food = ucwords(strtolower($posts_info['favorite_food'])); $least_favorite_food = ucwords(strtolower($posts_info['least_favorite_food'])); $favorite_school_subject = ucwords(strtolower($posts_info['favorite_school_subject'])); $least_favorite_school_subject = ucwords(strtolower($posts_info['least_favorite_school_subject'])); $strengths = ucwords(strtolower($posts_info['strengths'])); $weaknesses = ucwords(strtolower($posts_info['weaknesses'])); $goal = ucfirst($posts_info['goal']); $mission = ucfirst($posts_info['mission']); $biography = nl2br($posts_info['biography']); $biography = str_replace("\n", "<p>", $biography ); $getMonth = date('F', mktime(0, 0, 0, $birth_month)); $character_attack_level = $posts_info['attack_level']; $get_images = "select * from upload where identity = '$identity'"; $get_images_res = mysql_query($get_images, $conn) or die(mysql_error()); while ($images_info = mysql_fetch_array($get_images_res)) { $image_id = $images_info['id']; $image_identity = $images_info['identity']; $image_name = $images_info['name']; $image_type = $images_info['type']; $image_size = $images_info['size']; $image_content = $images_info['content']; //add to display $display_block .= " <tr> <td width=24% valign=top><strong>Character Name:</strong></td> <td width=55% valign=top>$name</td> <td align=center valign=top rowspan=18><img src='download.php?id=$image_id'></td> </tr> <tr> <td><strong>Element Of Influence:</strong></td> <td>$element_of_influence</td> </tr> <tr> <td><strong>Age:</strong></td> <td>$age</td> </tr> <tr> <td><strong>Date Of Birth:</strong></td> <td>$getMonth $birth_date, $birth_year</td> </tr> <tr> <td><strong>Height:</strong></td> <td>$height_feet feet $height_inches inches</td> </tr> <tr> <td><strong>Blood Type:</strong></td> <td>$blood_type</td> </tr> <tr> <td><strong>Hobbies:</strong></td> <td>$hobbies</td> </tr><tr> <td><strong>Favorite Color:</strong></td> <td>$favorite_color</td> </tr> <tr> <td><strong>Favorite Gemstone:</strong></td> <td>$favorite_gemstone</td> </tr> <tr> <td><strong>Favorite Food:</strong></td> <td>$favorite_food</td> </tr> <tr> <td><strong>Least Favorite Food:</strong></td> <td>$least_favorite_food</td> </tr> <tr> <td><strong>Favorite School Subject:</strong></td> <td>$favorite_school_subject</td> </tr> <tr> <td><strong>Least Favorite School Subject:</strong></td> <td>$least_favorite_school_subject</td> </tr> <tr> <td><strong>Strengths:</strong></td> <td>$strengths</td> </tr> <tr> <td><strong>Weaknesses:</strong></td> <td>$weaknesses</td> </tr> <tr> <td><strong>Goal:</strong></td> <td>$goal...</td> </tr> <tr> <td><strong>Mission:</strong></td> <td>$mission.</td> </tr> <td> </td> <td> </td> </tr> <tr> <td align=right colspan=3>Created By: <strong>$username</strong><br> Created On: <em>$character_create_time</em></td> </tr>"; } //close up the table $display_block .= "</table><br> <p>$biography</p><br>"; } } //gather stats and derived values; fix where statement $get_stats = "select * from stats where identity = '$identity'"; $get_stats_res = mysql_query($get_stats, $conn) or die(mysql_error()); $display_block .= " <table cellpadding=3 cellspacing=3 border=0 width=100%>"; while ($stats_info = mysql_fetch_array($get_stats_res)) { $body = $stats_info['body']; $mind = $stats_info['mind']; $soul = $stats_info['soul']; $display_block .= " <tr> <td valign=top> <table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables> <th colspan=3>Stats And Derived Values</th> <tr> <td>Body</td> <td class=align_levels>$body</td> <td> </td> </tr> <tr> <td>Mind</td> <td class=align_levels>$mind</td> <td> </td> </tr> <tr> <td>Soul</td> <td class=align_levels>$soul</td> <td> </td> </tr>"; } //gather derived values $get_derived = "select * from derived_values where identity = '$identity'"; $get_derived_res = mysql_query($get_derived, $conn) or die(mysql_error()); while ($derived_info = mysql_fetch_array($get_derived_res)) { $health = $derived_info['health']; $energy = $derived_info['energy']; $acv1 = $derived_info['acv1']; $acv2 = $derived_info['acv2'] . ' (for Sailor Scout Attack)'; $dcv1 = $derived_info['dcv1']; $dcv2 = $derived_info['dcv2'] . ' (for Sailor Scout Attack)'; $total_cp = $derived_info['total_cp']; if($health == 0 || $health == '0' || $health == null){$GLOBALS['health'] = "";} if($energy == 0 || $energy== '0' || $energy == null){$GLOBALS['energy'] = "";} if($acv1 == 0 || $acv1 == '0' || $acv1 == null){$GLOBALS['acv1'] = "";} if($acv2 == 0 || $acv2 == '0' || $acv2 == null){$GLOBALS['acv2'] = "";} if($dcv1 == 0 || $dcv1 == '0' || $dcv1 == null){$GLOBALS['dcv1'] = "";} if($dcv2 == 0 || $dcv2 == '0' || $dcv2 == null){$GLOBALS['dcv2'] = "";} if($total_cp == 0 || $total_cp == '0' || $total_cp== null){$GLOBALS['total_cp'] = "";} $display_block .= " <tr> <td colspan=3> </td> </tr> <tr> <td>Health Points</td> <td class=align_levels>$health</td> <td> </td> </tr> <tr> <td>Energy Points</td> <td class=align_levels>$energy</td> <td> </td> </tr> <tr> <td>Attack Combat Value</td> <td class=align_levels>$acv1</td> <td>$acv2</td> </tr> <tr> <td>Defense Combat Value</td> <td class=align_levels>$dcv1</td> <td>$dcv2</td> </tr> <tr> <td>Total Character Points</td> <td class=align_levels>$total_cp</td> <td> </td> </tr> </table><br>"; } //gather defects $get_defects = "select * from scout_defects where identity = '$identity'"; $get_defects_res = mysql_query($get_defects, $conn) or die(mysql_error()); $display_block .= " <table cellpadding=3 cellspacing=3 border=0 width=90% align=center class=list_tables> <th colspan=3>Character Defects</th>"; while ($defects_info = mysql_fetch_array($get_defects_res)) { $defects_id = $defects_info['id']; $defects_identity = $defects_info['identity']; $defects_id = $defects_info['defect_id']; $desc = $defects_info['desc']; $defects_level = $defects_info['level']; if($defects_info['desc'] != ""){ $desc = "(" . $defects_info['desc'] . ")"; }else{ $desc = ""; } $get_defects_names = "select * from defects where id = '$defects_id'"; $get_defects_names_res = mysql_query($get_defects_names, $conn) or die(mysql_error()); while ($defects_names_info = mysql_fetch_array($get_defects_names_res)) { $defects_names_id = $defects_names_info['id']; $defect = $defects_names_info['defect']; $display_block .= " <tr> <td>$defect $desc</td> <td>$defects_level</td> <td> </td> </tr>"; } } $display_block .= " </table></td>"; // gather attributes and sub-attributes $get_attributes = "select * from scout_attributes where identity = '$identity'"; $get_attributes_res = mysql_query($get_attributes, $conn) or die(mysql_error()); $display_block .= " <td valign=top> <table cellspacing=3 cellpadding=3 border=0 width=90% align=center class=list_tables> <th colspan=3>Character Attributes And Sub-Attributes</th> <tr> <td align=center><b>Attribute/Sub-Attribute</b></td> <td align=center><b>Level</td> <td align=center><b>Points</b></td> </tr>"; while ($attributes_info = mysql_fetch_array($get_attributes_res)) { $attributes_id = $attributes_info['id']; $attribute_identity = $attributes_info['identity']; $attribute_id = $attributes_info['attribute_id']; $attribute_level = $attributes_info['level_id']; $get_attribute_names = "SELECT * FROM attributes WHERE id = '$attribute_id'"; $get_attribute_names_res = mysql_query($get_attribute_names, $conn) or die(mysql_error()); while ($attribute_names_info = mysql_fetch_array($get_attribute_names_res)) { $attribute_names_id = $attribute_names_info['id']; $attribute_names_attribute = $attribute_names_info['attribute']; $attributes_names_points = $attribute_names_info['points']; $attributes_points = ($attributes_names_points * $attribute_level); $display_block .= " <tr> <td>$attribute_names_attribute</td> <td class=align_levels>$attribute_level</td> <td class=align_levels>$attributes_points</td> </tr>"; } }
-
I set it as two separate statements, but it works. Thanks guys!
$identity = $_SESSION['identity'];
$accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE identity = '$_SESSION[identity]'");
$accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE identity = '$_SESSION[identity]'");
-
Nevermind, I guess I figured it out. I had it saved in my session already since I had a session started. i just named a variable and set it to the session:
$identity = '$_SESSION[identity]';
Thanks anyway!
-
How do I save variables that are not posted from a form but are just being pulled from the database? I have the following page:
top part of the page:
//connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("smrpg", $conn) or die(mysql_error()); //verify the topic exists $verify_topic = "select identity from scouts where id = $_GET[id]"; $verify_topic_res = mysql_query($verify_topic, $conn) or die(mysql_error()); if (mysql_num_rows($verify_topic_res) < 1) { //this character does not exist $display_block = "<p><em>You have selected an invalid character. Please <a href=\"listcharacters.php\">try again</a></em></p>"; } else { //gather rest of profile $get_posts = "select *, date_format(create_time, '%b %e %Y at %r') as fmt_scout_create_time from scouts where id = $_GET[id]"; $get_posts_res = mysql_query($get_posts, $conn) or die(mysql_error()); //create the display string $display_block = " <table cellpadding=3 cellspacing=1 border=0 class=list_tables>"; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['id']; $identity = ucwords($posts_info['identity']); $character_create_time = $posts_info['fmt_scout_create_time']; $username = $posts_info['username']; $name = ucwords(strtolower($posts_info['name'])); $element_of_influence = $posts_info['element_of_influence']; $age = $posts_info['age']; $birth_month = $posts_info['birth_month']; $birth_date = $posts_info['birth_date']; $birth_year = $posts_info['birth_year']; $height_feet = $posts_info['height_feet']; $height_inches = $posts_info['height_inches']; $blood_type = strtoupper($posts_info['blood_type']); $hobbies = ucwords(strtolower($posts_info['hobbies'])); $favorite_color = ucwords(strtolower($posts_info['favorite_color'])); $favorite_gemstone = ucwords(strtolower($posts_info['favorite_gemstone'])); $favorite_food = ucwords(strtolower($posts_info['favorite_food'])); $least_favorite_food = ucwords(strtolower($posts_info['least_favorite_food'])); $favorite_school_subject = ucwords(strtolower($posts_info['favorite_school_subject'])); $least_favorite_school_subject = ucwords(strtolower($posts_info['least_favorite_school_subject'])); $strengths = ucwords(strtolower($posts_info['strengths'])); $weaknesses = ucwords(strtolower($posts_info['weaknesses'])); $goal = ucfirst($posts_info['goal']); $mission = ucfirst($posts_info['mission']); $biography = nl2br($posts_info['biography']); $biography = str_replace("\n", "<p>", $biography ); $getMonth = date('F', mktime(0, 0, 0, $birth_month)); $character_attack_level = $posts_info['attack_level'];
And I want to save the sessions for $identity and $userName from the following script lower on the page:
<?php if (isset($_SESSION['loggedIn']) == 1) { ?> <p>Welcome, <?php echo $_SESSION['userName'] ?> (<a href="login.php?action=logoff" title="Log Out">Log Out</a>)</p> <?php } else { ?> <p>Please <a href="login.php">log in</a></p> <?php } ?>
I want to save those variables into sessions on this page:
<?php session_start(); //connect to server and select database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("smrpg", $conn) or die(mysql_error()); $accept_scout = mysql_query("UPDATE scouts SET username = '$_SESSION[userName]' AND available = '0' WHERE identity = '$_SESSION[identity]'"); ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> You have accepted the character. </body> </html>
So I can use them in the update statement. Can anyone help explain how I can do this?
-
If you need any help, here is a tutorial I used:
http://www.tutorialized.com/view/tutorial/Simple-Chatbox-in-PHP-MySQL/23971
I just changed and used longtext for the message.
And you can always display the contents without adding the form for users to add messages, or you can add that later if you decide you want it. :-) Hope that help :-)
Timed Redirect?
in PHP Coding Help
Posted
It was on another page, sorry. It was a typo. On this page I am using $scout_id.