Script Help

Hello All,

I am working with a members website and well i am trying to get the memberid # from the db to show up on a form as the members name.

Well I got that much but when the form is submitted by the member, it goes to another script but the id or name do not transfer over to the next page. I have tried to change the variable name and I have written a test pageso it “prints” on the screen so I can see it before trying to add the information to a table.

The whole idea is to have the id added to the new table so when scripts look up the information it is all associated by the id #.

I think I made a mistake in the form script but can’t see where it is.

Here is the portion of the code related to this issue if anyone see my mistake please let me know.

Add Character <?php include("misc.inc"); //8 $conn = mysql_connect($msql_server, $msql_user, $msql_password) or die ("Unable to Connect");

mysql_select_db($msql_db, $conn) or die (“Unable to Connect to DB”);
$query = “SELECT * FROM memberinformation”;

$result = mysql_query($query) or die (“Couldn’t execute query.”);

echo “n”;

echo ‘

’;
echo ‘’;
echo ‘’;
echo ‘’;
echo ‘’;

echo ‘

’;
echo ‘’;
echo ‘’;
echo ‘’;

echo ‘

’;
echo ‘’;
echo ‘’;
echo ‘’;

echo ‘

’;
echo ‘’;
echo ‘’;
echo ‘’;

echo ‘

’;
echo ‘’;
echo ‘’;
echo ‘
’;
echo ‘Players Name:’;
echo ‘
’;
echo “n”;
while ($row = mysql_fetch_array($result))
{
extract($row);
$name = “$memFirstName $memSurname”;
echo “$namen”;
$name = “$memberID”; ****** this is probably my mistake but even pulling this doesn’t get me the info I need.
}
echo “n”;
echo ‘
’;
echo ‘Character Name:’;
echo ‘
’;
echo ‘’;
echo ‘
’;
echo ‘Which Character:’;
echo ‘
’;
echo “primaryn”;
echo “secondaryn”;
echo “tertiaryn”;
echo “quaternaryn”;
echo “quinaryn”;
echo ‘
’;
echo ‘Notes:’;
echo ‘
’;
echo ‘’;
echo ‘
’;
echo ‘

’;
echo ‘’;
echo ‘’;
echo ‘

’;
echo “n”;
?>

Now the page that accepts the form info.

<?php

include("…/misc.inc");
$name = $_POST [’$name’];
$characterName = $_POST [‘characterName’];
$wchar = $_POST [‘wchar’];
$characterNotes = $_POST [‘characterNotes’];

echo “

”;
echo “”;
echo “n
n
n
n
n
n”;
echo “n”;

echo “


$memberID $characterName $wchar $characterNotes

n”;
?>

Ok so thats what I got any help would be appreciated.

Try this


<html>
<head>
<title>Add Character</title>
</head>
<body>
<?php
include("misc.inc");
//8
$conn = mysql_connect($msql_server, $msql_user, $msql_password) or die ("Unable to Connect");

mysql_select_db($msql_db, $conn) or die ("Unable to Connect to DB");
$query = "SELECT * FROM memberinformation";

$result = mysql_query($query) or die ("Couldn't execute query.");
?>
<form action='addchar.php' method='POST'>
  <table border="0">
    <tr>
      <td align="right"><b>Players Name:</b></td>
      <td><select name='Players Name'>
          <?
while ($row = mysql_fetch_array($result))
{
extract($row); 
$name = "$memFirstName $memSurname";
?>
          <option value='name'>
          <?
$mem_id = "$memberID"; /* Error here $name */
} ?>
        </select>
      </td>
    </tr>
    <tr>
      <td align="right"><b>Character Name:</b></td>
      ';
      <td><input type="text" name="characterName" size="20"></td>
      '; </tr>
    <tr>
      <td align="right"><b>Which Character:</b></td>
      ';
      <td><input type='radio' name='wchar' value='primary'>
        primary
        <input type='radio' name='wchar' value='secondary'>
        secondary
        <input type='radio' name='wchar' value='tertiary'>
        tertiary
        <input type='radio' name='wchar' value='quaternary'>
        quaternary
        <input type='radio' name='wchar' value='quinary'>
        quinary </td>
    </tr>
    <tr>
      <td align="right"><b>Notes:</b></td>
      <td><textarea name="characterNotes" cols="30" rows="8"></textarea>
        '; </td>
    </tr>
    <tr>
      <td align="right"><p>
          <input type="hidden" name="mem_id" value="<? echo $mem_id ?>">
          <input type="hidden" name="name" value="<? echo $name ?>">
          <input type="submit" value="ADD">
          <input type="reset" value="RESET">
      </td>
    </tr>
  </table>
</form>
</body>
</html>

I have taken the liberty of cleaning it up a bit.

andy thanks for the help.

I left it as a php page so the echo’s are needed. Tried it the way you rewrote it and it just didnt pull the arrarys in for me.

After I converted this script to php with the echos it worked but i am still unable to get the mem_id to show up on the post screen.

Basically what I am workign with is a members game db. What I am trying to do is after creating the members info there is an autogenerated member id. I then access a character creation page which pulls allthe members in to a drop down menu so i can select the name of who i want the character associated with.

I know how to pull the members info and put it in the menu but i can’t figure out how to store the member’s id as a hidden value so when the page is submitted the member id posts to the next script and is stored in the character table. Basically I want to use the member id to associate all the records.

Are there any tutorials i can look at that help explain how to deal with array info pulled from a db or how to set up a script to show the description from the array but post the id thats in the array so it is stored in a db.

I am just stuck right now so any help in where to find a tutorial on this or any suggestions would be appreciated.

Thanks

Hello i look over and over the world wide web for php help. i hope i can find it here… I have very little know how on it… but am trying to learn. Ok i run a web chat site. and i got my members page for a chat gallery… trouble is i cant get then name in order like Alice, Art then in if like i add Andy. Andy will not be between Alice and Art. So im hoing some one can help me… This is one tihng i like to fix… i inclose the php code i am using… hoping some one can help me out. The guy that made this for me. I have not seen in over a year.

<?php $db_name = "######"; /* this is the database username */ $db_pw = "#########"; /* this is the database password */ $gal_pics = "../Graphics/"; /* this is the folder name where the gallery pics are. end it with a slash */ $folder = "../Graphics/"; /* this is the folder name the gallery.php file lives in, ie gallery/ must end the name with a slash */ ?> Comic Chat Server The Crypt-The Gallery body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; color: #FF0000; } body { background-image: url(../Graphics/layout.jpg); background-color: #000; background-repeat: no-repeat; } .main { position:absolute; width:50px; height:50px; color:red; background-color:transparent; border: 2px solid red; padding: 5px; text-align:center; font-weight:bold; text-decoration:none; display:block; z-index:1; } .drop { position:absolute; width:100px; font-family:Arial; font-size:14; font -weight:normal; color:#FF0000; text-decoration:none; background-color:#000000; padding: 5px; display:none; z-index:2; border: 2px groove #FF0000; } html>body .drop{ /* this is more firefox */ margin-top:-220px; margin-left:5px; position:relative; border: 2px solid #FF0000; } @media all and (min-width: 0px){ /* this is for opera */ .drop { position: relative; height: 850px; } }.droptext { font-family:Arial; font-size:14; color:red; text-decoration:none; } .droptext:hover { color:#990000; text-decoration:underline; } a:link { color: #3366FF; } a:visited { color: #00FF33; } a:hover { color: #00FF00; } a:active { color: #CC33FF; } #Layer5 { position:absolute; width:162px; height:54px; z-index:16; left: 351px; top: 135px; } #Layer6 { position:absolute; width:167px; height:56px; z-index:17; left: 521px; top: 137px; }
<td width="93%"><div id="Layer11" style="position:absolute; width:200px; height:115px; z-index:12; left: 399px; top: 7px;"><a href="../index.html"><img src="../Graphics/Welcome.gif" alt="Welcome to the Crypt" width="381" height="55" border="0"></a></div></td>
<td width="0%">&nbsp;</td>
   
 
Op's Page
    <div id="Layer5"><a href="mic://www.crypthome.com/#Crypt"><img src="../Graphics/Server.gif" alt="To Crypt Server" width="180" height="61" border="0"></a></div>
    <div id="Layer6"><a href="../Forum/index.php"><img src="../Graphics/Forum.gif" alt="To Crypt Forum" width="180" height="61" border="0"></a></div>
    <div id="Layer9" style="position:absolute; width:188px; height:63px; z-index:10; left: 175px; top: 7px;"><a href="gallery.php"><img src="../Graphics/Gallery.gif" alt="Comic Chatters Gallery" width="146" height="61" border="0"></a></div>
    <div id="Layer10" style="position:absolute; width:152px; height:58px; z-index:11; left: 701px; top: 138px;"><a href="http://www.crypthome.net/"></a><img src="../Graphics/net1.gif" width="180" height="61"></div>
  </div></td>
<td><div align="right"></div></td>
   

 

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

<?php /* database connection */ $dbcnx = mysql_connect("localhost", $db_name, $db_pw); if(!$dbcnx) { echo "

Unable to connect to database server

"; exit(); } if(!@mysql_select_db("chat_gallery")) { echo "

Unable to connect to database

"; exit(); } $sqlquery = "SELECT * FROM gallery WHERE approved='y' order by letter_num asc"; $result = @mysql_query($sqlquery); if (@mysql_num_rows($result) != 0) { $gallery_content = ""; $cycle_in = 1; $cycle_out = 0; $content = 'yes'; while($row = mysql_fetch_assoc($result)) { if($cycle_in <= $cycle_out) { $gallery_content .= "n"; $cycle_in++; } if($cycle_out >= $row['letter_num']) { if($row['name'] == '' && $content == 'no') { $gallery_content .= "tMembers are:
n"; }else{ $the_name = str_replace('_', ' ', $row[name]); $gallery_content .= "t$the_name
n"; $content = 'yes'; } }else{ if($content != 'yes') { $gallery_content .= "tLetter empty
n"; } $cycle_out++; $gallery_content .= "
n"; $content = 'no'; } } } echo $gallery_content; echo ""; ?>
Are you not here? Click on the coffin and add yourself.
 
Sponsor our Newsletter | Privacy Policy | Terms of Service