Jump to content

Recommended Posts

orly2.jpg

 

I need help modifying/adding/fixing my script so that after the NPC id field is filled in and the user hits enter, the Display Id field updates with the number from the query result.

<!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>index</title>
<style type="text/css">
<!--
body {
background-color: #000;
}
body,td,th {
color: #FFF;
}
-->
</style></head>

<body>
<h1 align="center">Display Id Lookup Tool</h1>
<p align="center">Created By: Vindicated</p>
<form id="form1" name="form1" method="post" action="">
  <p align="center"> </p>
  <p align="center">
    <label>NPC 
      
      Id:
<input type="text" name="npcid" id="npcid" />
      Display Id:
    </label> 
    <input name="displayid" type="text" id="displayid" value="" size="45" />
  </p>
  <p align="center">
    <input type="submit" name="submit" id="submit" value="Submit" />
  </p>
</form>
<?php
$servername = "localhost:3306";
$username = "root";
$password = "gojags";
$worlddb = "twink_world";

mysql_connect($servername, $username, $password);

mysql_select_db($worlddb, $connection);

$result = mysql_query("SELECT male_displayid FROM creature_names");

while($row = mysql_fetch_array($result))
{
echo $_GET[$result];
}

echo '<displayid>'.$row[male_displayid].'</displayid>';

mysql_close($connection)
?>
<p>*Created by Vindicated for MMOwned.com. Unacceptable for public use without permission.*</p>
</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/147665-update-field-text/
Share on other sites

r u looking for something liek this ? u have to change the field name to the one in ur table for npcid, also i have moved php code above HTML code.

 

<?php
$servername = "localhost:3306";
$username = "root";
$password = "gojags";
$worlddb = "twink_world";

mysql_connect($servername, $username, $password);
mysql_select_db($worlddb, $connection);

if($_POST['npcid']) {

$result = mysql_query("SELECT male_displayid FROM creature_names WHERE npcid = '".$_POST['npcid']."'"); // change WHERE npcid to field name in ur DB.
$row = mysql_fetch_array($result))
$DisplayId = $row['male_displayid'];
}
?>
<!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>index</title>
<style type="text/css">
<!--
body {
background-color: #000;
}
body,td,th {
color: #FFF;
}
-->
</style></head>

<body>
<h1 align="center">Display Id Lookup Tool</h1>
<p align="center">Created By: Vindicated</p>
<form id="form1" name="form1" method="post" action="">
  <p align="center"> </p>
  <p align="center">
    <label>NPC 
      
      Id:
<input type="text" name="npcid" id="npcid" />
      Display Id:
    </label> 
    <input name="displayid" type="text" id="displayid" value="<?php if (isset($DisplayId)) echo $DisplayId; ?>" size="45" />
  </p>
  <p align="center">
    <input type="submit" name="submit" id="submit" value="Submit" />
  </p>
</form>

<p>*Created by Vindicated for MMOwned.com. Unacceptable for public use without permission.*</p>
</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-775931
Share on other sites

One more minor problem. here is the script in its entirety

<!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>index</title>
<style type="text/css">
<!--
body {
   background-color: #000;
}
body,td,th {
   color: #FFF;
}
-->
</style></head>

<body>
<h1 align="center">Display Id Lookup Tool</h1>
<p align="center">Created By: Vindicated</p>
<form id="form1" name="form1" method="post" action="">
  <p align="center"> </p>
  <p align="center">
    <label>NPC
     
      Id:
<input type="text" name="npcid" id="npcid" />
      Display Id:
    </label>
    <input name="displayid" type="text" id="displayid" value="<?php if (isset($DisplayId)) echo $DisplayId; ?>" size="45" />
  </p>
  <p align="center">
    <input type="submit" name="submit" id="submit" value="Submit" />
  </p>
</form>

<p>*Created by Vindicated for MMOwned.com. Unacceptable for public use without permission.*</p>
</body>

</html>
<?php
$servername = "localhost:3306";
$username = "root";
$password = "gojags";
$worlddb = "twink_world";

$connection = mysql_connect($servername, $username, $password);
mysql_select_db($worlddb, $connection);

if($_POST['npcid']) {

   $result = mysql_query("SELECT male_displayid FROM creature_names WHERE npcid = '".$_POST['npcid']."'"); // change WHERE npcid to field name in ur DB.
   $row = mysql_fetch_array($result);
   $DisplayId = $row['male_displayid'];
}
?>

 

And the error I get is:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 46

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 47

Notice: Undefined index: npcid in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 49

before using it

 

and

*Created by Vindicated for MMOwned.com. Unacceptable for public use without permission.*

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 46

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 47

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 51

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 51

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 52

 

After. Also how could I add a message to display if the ID does not exsist?

Link to comment
https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-777053
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.