Jump to content

[SOLVED] Problems


Msword

Recommended Posts

<?php
require("dbconnect.php");
mysql_select_db("runecrypt", $sql);
if (isset($_GET['pid']) == 0) {
print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
  <title></title>
</head>
<body>
<form method="get" name="edit">
  <table
style="text-align: left; margin-left: auto; margin-right: auto; width: 325px; height: 61px;"
border="1" cellpadding="2" cellspacing="2">
    <tbody>
      <tr>
        <td style="text-align: center;">Person to edit PID</td>
        <td><input name="pid"></td>
      </tr>
    </tbody>
  </table>
  <div style="text-align: center;"><input value="Submit"
type="submit"><br>
  </div>
</form>
<form method="get" action=" " name="edit"></form>
</body>
</html>';
}
if (isset($_POST['name'])) {
echo "124142";
echo "god damn not sposed to be here";
$name = $_POST["name"];
$pictureurl = $_POST["pictureurl"];
$exinfo = $_POST["exinfo"];
$dsc = $_POST["dsc"];
$location = $_POST["location"];
$quest = $_POST["quest"];
$membonly = $_POST["membonly"];
$contributors = $_POST["contributors"];
$date = date("F j, Y, g:i a");
mysql_query("UPDATE pdatabase SET name='$name', pictureurl='$pictureurl', exinfo='$exinfo', dsc='$dsc', location='$location', quest='$quest',  membonly='$membonly', contributors='$contributors', lastupdate='$date' WHERE pid=$pid");
}
if (isset($_GET['pid']))  {
echo "1312";
$pid = mysql_real_escape_string($_GET["pid"]);
$result = mysql_query("SELECT * FROM pdatabase
WHERE pid='$pid'") or die(mysql_error());
while($row = mysql_fetch_array($result))
  {
echo '<html>
<head>

  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <title>Add Person to Database</title>


</head>



<body>

<div style="text-align: center;">
<h2><span style=\"color: rgb(255, 0, 0);\"><a href="editperson.php">Refresh Page</a></span></h2>
<form method="post" action="editperson.php" name="edititem">Edit
Person in Database<br>

  <table style="text-align: left; margin-left: auto; margin-right: auto; height: 374px; width: 661px;" border="1" cellpadding="2" cellspacing="2">

    <tbody>

      <tr>

        <td style="width: 140px; text-align: center;">Name</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['name'] . '" input maxlength="40" size="40" name="name"></td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Picture
Name</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['pictureurl'] . 'input maxlength="255" size="40" name="pictureurl"><span style="text-decoration: underline;"><br>

        </span><span style="font-family: monospace;">full link please(http://draftx.net/test/pictures/nopic.png)<br>
nopic.png if none</span></td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Examine
Info</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['examine'] . 'textarea cols="40" rows="5" name="exinfo"></textarea><br>

What it says when you examine the person</td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Description</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['desc'] . 'textarea cols="40" rows="5" name="dsc"></textarea><br>

About the person, any extra information</td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Location</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['location'] . 'input maxlength="50" size="40" name="location"><br>

        <pre><a href="AreaURL">AreaName</a></pre>

        </td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Quests</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['quest'] . 'textarea cols="40" rows="5" name="quest"></textarea><br>

        <pre><a href="QuestURL">QuestName</a><br>Put <br> after every line<br>None if person is involved in no quests</pre>

        </td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Members
Only</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['membonly'] . 'input maxlength="5" size="5" name="membonly"><br>

Yes/No</td>

      </tr>

      <tr>

        <td style="text-align: center;">Contributors</td>

        <td style="text-align: center;"><input value="' . $row['contributors'] . 'textarea cols="40" rows="5" name="contributors"></textarea><br>
        <pre><a href="ContibutorForumURL">ContributorName</a></pre>
        </td>

      </tr>

    </tbody>
  </table>

  <input value="Submit" type="submit"></form>

</div>

</body>
</html>';
}
}
?>

I think the problem is the logic, 1312 and 124142(these are just for testing) get displayed, but it doesn't go to the last page like its sposed to.

Link to comment
Share on other sites

No, i'm checking to see if the variable is set, so i know what i need to do.

maybe but i said it on the first post i have doing that is wrong

 

var_dump(isset($_GET['pid']); this = false

 

if (isset($_GET['pid']) == 0) { this is the same as ! isset($_GET['pid']) or not isset

 

now is that what you want

Link to comment
Share on other sites

i dont know if im helping you but you need to restructure your code

 

look

$result = mysql_query("SELECT * FROM pdatabase
WHERE pid='$pid'") or die(mysql_error());
while($row = mysql_fetch_array($result))
  {
echo '<html>
<head>

  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <title>Add Person to Database</title>


</head>




 

what do you mean with the while loop loop the html page for several time

or maybe no because you only use ID for the condition

Link to comment
Share on other sites

that is part of your code and u are attempting to use WHILE LOOOP please see the code  i post on your code are trying to loop the declaration of new html??

 

i guess change all my comment first then post the new code where we can start looking

Link to comment
Share on other sites

wth the damn edit button disappeared....

$name = $_POST["name"];
$pictureurl = $_POST["pictureurl"];
$exinfo = $_POST["exinfo"];
$dsc = $_POST["dsc"];
$location = $_POST["location"];
$quest = $_POST["quest"];
$membonly = $_POST["membonly"];
$contributors = $_POST["contributors"];
$date = date("F j, Y, g:i a");
mysql_query("UPDATE pdatabase SET name='$name', pictureurl='$pictureurl', exinfo='$exinfo', dsc='$dsc', location='$location', quest='$quest',  membonly='$membonly', contributors='$contributors', lastupdate='$date' WHERE pid=$pid");
}
if (isset($_GET['pid']))  {
echo "1312";
$pid = mysql_real_escape_string($_GET["pid"]);
$result = mysql_query("SELECT * FROM pdatabase
WHERE pid='$pid'") or die(mysql_error());
while($row = mysql_fetch_array($result))
  {
echo '<html>
<head>

  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <title>Add Person to Database</title>


</head>



<body>

<div style="text-align: center;">
<h2><span style=\"color: rgb(255, 0, 0);\"><a href="editperson.php">Refresh Page</a></span></h2>
<form method="post" action="editperson.php" name="edititem">Edit
Person in Database<br>

  <table style="text-align: left; margin-left: auto; margin-right: auto; height: 374px; width: 661px;" border="1" cellpadding="2" cellspacing="2">

    <tbody>

      <tr>

        <td style="width: 140px; text-align: center;">Name</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['name'] . '" input maxlength="40" size="40" name="name"></td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Picture
Name</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['pictureurl'] . '" input maxlength="255" size="40" name="pictureurl"><span style="text-decoration: underline;"><br>

        </span><span style="font-family: monospace;">full link please(http://draftx.net/test/pictures/nopic.png)<br>
nopic.png if none</span></td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Examine
Info</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['examine'] . '" textarea cols="40" rows="5" name="exinfo"></textarea><br>

What it says when you examine the person</td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Description</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['desc'] . '" textarea cols="40" rows="5" name="dsc"></textarea><br>

About the person, any extra information</td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Location</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['location'] . '" input maxlength="50" size="40" name="location"><br>

        <pre><a href="AreaURL">AreaName</a></pre>

        </td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Quests</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['quest'] . '" textarea cols="40" rows="5" name="quest"></textarea><br>

        <pre><a href="QuestURL">QuestName</a><br>Put <br> after every line<br>None if person is involved in no quests</pre>

        </td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Members
Only</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['membonly'] . '" input maxlength="5" size="5" name="membonly"><br>

Yes/No</td>

      </tr>

      <tr>

        <td style="text-align: center;">Contributors</td>

        <td style="text-align: center;"><input value="' . $row['contributors'] . '" textarea cols="40" rows="5" name="contributors"></textarea><br>
        <pre><a href="ContibutorForumURL">ContributorName</a></pre>
        </td>

      </tr>

    </tbody>
  </table>

  <input value="Submit" type="submit"></form>

</div>

</body>
</html>';

i have narrowed it down to something being wrong with this, its getting executed, but not doing what it's sposed to.

Link to comment
Share on other sites

if (isset($_GET['pid']))  {
echo "1312";
$pid = mysql_real_escape_string($_GET["pid"]);
$result = mysql_query("SELECT * FROM pdatabase
WHERE pid='$pid'") or die(mysql_error());
while($row = mysql_fetch_array($result))
  {

 

the error may be in the if or while

 

echo you get variable to see if you get your expected data

then

print_r($row); to see if the result is not 0 zeroooo

 

 

and again this is wrong with the logic you have in the script

while($row = mysql_fetch_array($result))

  {

Link to comment
Share on other sites

I think its the update, would this show an error if there was one?

mysql_query("UPDATE pdatabase SET name='$name', pictureurl='$pictureurl', exinfo='$exinfo', dsc='$dsc', location='$location', quest='$quest',  membonly='$membonly', contributors='$contributors', lastupdate='$lastupdate' WHERE pid=$pid") or die(mysql_error());

 

it just says 'Mysql error'

Link to comment
Share on other sites

dude you have allot of bug or structuring prob

look

if (isset($_POST['name'])) {
echo "124142";
echo "god damn not sposed to be here";
$name = $_POST["name"];
$pictureurl = $_POST["pictureurl"];
$exinfo = $_POST["exinfo"];
$dsc = $_POST["dsc"];
$location = $_POST["location"];
$quest = $_POST["quest"];
$membonly = $_POST["membonly"];
$contributors = $_POST["contributors"];
$date = date("F j, Y, g:i a");
mysql_query("UPDATE pdatabase SET 
				name = '$name', 
				pictureurl = '$pictureurl',
				exinfo = '$exinfo', 
				dsc = '$dsc', 
				location = $location',
				quest = '$quest', 
				membonly = '$membonly', 
				ontributors = '$contributors', 
				lastupdate = '$date' 
				WHERE pid = $pid");

i reformat that but i found thid ^^^^^^^^ WHERE pid = $pid"  where is $pid set

Link to comment
Share on other sites

<?php
require("dbconnect.php");
mysql_select_db("runecrypt", $sql);
if (isset($_GET['pid']) == 0 and isset($_POST['name']) == 0) {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
  <title></title>
</head>
<body>
<form method="get" name="edit">
  <table
style="text-align: left; margin-left: auto; margin-right: auto; width: 325px; height: 61px;"
border="1" cellpadding="2" cellspacing="2">
    <tbody>
      <tr>
        <td style="text-align: center;">Person to edit PID</td>
        <td><input name="pid"></td>
      </tr>
    </tbody>
  </table>
  <div style="text-align: center;"><input value="Submit" action="addperson.php" type="submit"><br>
  </div>
</form>
<form method="get" name="edit"></form>
</body>
</html>';
}
if (isset($_POST['name'])) {
echo "123456";
$pid = $_POST["pid"];
echo $pid;
echo 'hello world';
$name = $_POST["name"];
$pictureurl = $_POST["pictureurl"];
$exinfo = $_POST["exinfo"];
$dsc = $_POST["dsc"];
$location = $_POST["location"];
$quest = $_POST["quest"];
$membonly = $_POST["membonly"];
$contributors = $_POST["contributors"];
$lastupdate = date("F j, Y, g:i a");
mysql_query("UPDATE pdatabase SET name='$name', pictureurl='$pictureurl', exinfo='$exinfo', dsc='$dsc', location='$location', quest='$quest',  membonly='$membonly', contributors='$contributors', lastupdate='$lastupdate' WHERE pid='$pid'") or die("Mysql error");
}
if (isset($_GET['pid']))  {
echo "1312";
$pid = mysql_real_escape_string($_GET["pid"]);
$result = mysql_query("SELECT * FROM pdatabase
WHERE pid='$pid'") or die(mysql_error());
while($row = mysql_fetch_array($result))
  {
echo '<html>
<head>

  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <title>Add Person to Database</title>


</head>



<body>

<div style="text-align: center;">
<h2><span style=\"color: rgb(255, 0, 0);\"><a href="editperson.php">Refresh Page</a></span></h2>
<form method="post" action="editperson.php" name="edititem">
<input type="hidden" id="pid" value="' . $row['pid'] . '"/>
Edit
Person in Database<br>


  <table style="text-align: left; margin-left: auto; margin-right: auto; height: 374px; width: 661px;" border="1" cellpadding="2" cellspacing="2">

    <tbody>

      <tr>

        <td style="width: 140px; text-align: center;">Name</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['name'] . '" input maxlength="40" size="40" name="name"></td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Picture
Name</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['pictureurl'] . '" input maxlength="255" size="40" name="pictureurl"><span style="text-decoration: underline;"><br>

        </span><span style="font-family: monospace;">full link please(http://draftx.net/test/pictures/nopic.png)<br>
nopic.png if none</span></td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Examine
Info</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['examine'] . '" textarea cols="40" rows="5" name="exinfo"></textarea><br>

What it says when you examine the person</td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Description</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['desc'] . '" textarea cols="40" rows="5" name="dsc"></textarea><br>

About the person, any extra information</td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Location</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['location'] . '" input maxlength="50" size="40" name="location"><br>

        <pre><a href="AreaURL">AreaName</a></pre>

        </td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Quests</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['quest'] . '" textarea cols="40" rows="5" name="quest"></textarea><br>

        <pre><a href="QuestURL">QuestName</a><br>Put <br> after every line<br>None if person is involved in no quests</pre>

        </td>

      </tr>

      <tr>

        <td style="width: 140px; text-align: center;">Members
Only</td>

        <td style="width: 415px; text-align: center;"><input value="' . $row['membonly'] . '" input maxlength="5" size="5" name="membonly"><br>

Yes/No</td>

      </tr>

      <tr>

        <td style="text-align: center;">Contributors</td>

        <td style="text-align: center;"><input value="' . $row['contributors'] . '" textarea cols="40" rows="5" name="contributors"></textarea><br>
        <pre><a href="ContibutorForumURL">ContributorName</a></pre>
        </td>

      </tr>

    </tbody>
  </table>

  <input value="Submit" action="editperson.php" type="submit"></form>

</div>

</body>
</html>';
}
}
?>

that is current code.

is it now the way $pid i get get[pid] because that seems to not be working?

Link to comment
Share on other sites

Ok, what is happening, its going to the first form, i put in a number, it takes me to the form where it has everything filled in. I submit the form, having changed a few things, and they don't change, no errors, and it brings me to a page where it says '123456hello world' like it is made to. I need the thing to get updated.

 

pid isn't getting echo'd and i think that is the problem, why isn't it getting echo'd?

is something wrong with getting this from the form:

<input type="hidden" id="pid" value="' . $row['pid'] . '"/>

Link to comment
Share on other sites

this should work if the $pid is really set

mysql_query("UPDATE pdatabase SET name='".$name."', 
								pictureurl='".$pictureurl."', 
								exinfo='".$exinfo."', 
								dsc='".$dsc."', 
								location='".$location."', 
								quest='".$quest."',  
								membonly='".$membonly."', 
								contributors='".$contributors."', 
								lastupdate='".$lastupdate."' 
								WHERE pid=".$pid."")

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.