ORLYman Posted March 3, 2009 Share Posted March 3, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/ Share on other sites More sharing options...
ORLYman Posted March 4, 2009 Author Share Posted March 4, 2009 Bump! Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-775927 Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-775931 Share on other sites More sharing options...
ORLYman Posted March 4, 2009 Author Share Posted March 4, 2009 Parse error: parse error in C:\wamp\www\Vindicated's Display Id Lookup Tool\index.php on line 13 Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-776019 Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 sorry forgot semicolon on line 13 $row = mysql_fetch_array($result)); Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-776483 Share on other sites More sharing options...
ORLYman Posted March 5, 2009 Author Share Posted March 5, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-777053 Share on other sites More sharing options...
samshel Posted March 5, 2009 Share Posted March 5, 2009 the error speaks for itself, it is not able to connect to mysql as user/password are not correct. Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-777669 Share on other sites More sharing options...
ORLYman Posted March 6, 2009 Author Share Posted March 6, 2009 But it is :S Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-778411 Share on other sites More sharing options...
revraz Posted March 6, 2009 Share Posted March 6, 2009 Access Denied means just that. The ID/PW doesn't have connect rights. Quote Link to comment https://forums.phpfreaks.com/topic/147665-update-field-text/#findComment-778417 Share on other sites More sharing options...
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.