Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource

Reply

Join Date: Mar 2008
Posts: 1
Reputation: dw-heath is an unknown quantity at this point 
Solved Threads: 0
dw-heath dw-heath is offline Offline
Newbie Poster

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource

 
0
  #1
Mar 20th, 2008
Hello, I am having difficulties with this, I have been working weeks on getting a site finished and I'm down to the last couple of pages and this has become irritating. If you could help I would be very thankful.

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/chaoskni/public_html/admin/insert.php on line 17
Error:


This is the edit_members.php code. (not the one displaying the error)
  1. <?php
  2. require("auth.php");
  3. $rank_array = array("1" => "Founder",
  4. "Leader",
  5. "Commander",
  6. "Co-Commander",
  7. "General",
  8. "Lieutenant General",
  9. "Major General",
  10. "Brigadier General",
  11. "Colonel",
  12. "Lieutenant Colonel",
  13. "Major",
  14. "Captain",
  15. "First Lieutenant",
  16. "Second Lieutenant",
  17. "Master Warrant Officer CWO5",
  18. "Chief Warrant Officer CWO4",
  19. "Chief Warrant Officer CWO3",
  20. "Chief Warrant Officer CWO2",
  21. "Warrant Officer WO1",
  22. "Sergeant Major",
  23. "First Sergeant",
  24. "Master Sergeant",
  25. "Sergeant First Class",
  26. "Staff Sergeant",
  27. "Sergeant",
  28. "Corporal",
  29. "Private: First Class",
  30. "Private",
  31. "Recruit");
  32. @include '../f/fileid.php';
  33. $connect = mysql_connect($db_host,$db_username,$db_password)or die ("no connect");
  34. mysql_select_db($db_name)or die ("no select");
  35. ?>
  36.  
  37. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  38. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  39. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  40. <head>
  41. <title>Chaos Knights :: Knights of the Evil Realm</title>
  42.  
  43. <script type="text/javascript" src="../js/dropdown.js">
  44.  
  45. /***********************************************
  46. * Drop Down Tabs Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
  47. * This notice MUST stay intact for legal use
  48. * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
  49. ***********************************************/
  50.  
  51. </script>
  52. <!-- CSS for Drop Down Tabs Menu #1 -->
  53. <link rel="stylesheet" type="text/css" href="../css/ddcolortabs.css" />
  54. <link rel="stylesheet" type="text/css" href="../css/website2.css" />
  55. <style type="text/css">
  56. .style1 {
  57. font-weight: normal;
  58. }
  59. </style>
  60. </head>
  61. <body>
  62.  
  63. <table style="width: 100%" cellspacing="0" cellpadding="0">
  64. <tr>
  65. <td colspan="3" id="banner">
  66. <img alt="" src="../img/banner-left.png" width="504" height="200" /></td>
  67. </tr>
  68. <tr>
  69. <td colspan="3" id="navigation" style="height: 21px">
  70. <?
  71. @include '../f/include/user/navigation2.php';
  72. ?>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td width="20%" valign="top" class="left"><span class="style1"><em><?php include '../f/include/user/left.php'; ?></em></td>
  77. <td valign="top" width="60%" class="middle"><blockquote>
  78. <p>
  79. You can use this page to manage the roster/memberlist.<br/>
  80. To begin, click 'Show' next to the task you wish to perform.
  81. </p>
  82. <p>
  83. You can use this page to manage the roster/memberlist.<br/>
  84. To begin, click 'Show' next to the task you wish to perform.
  85. </p>
  86. Add Member : (<a href='#' onclick='document.getElementById("add").style.display = "block"; return false;'>Show</a> / <a href='#' onclick='document.getElementById("add").style.display = "none"; return false;'>Hide</a>)
  87. <div style='display: none;' id='add'>
  88. <form action="insert.php" method="post">
  89. <table border="0" width="500" cellspacing="0" cellpadding="0" id="table1">
  90. <tr>
  91. <td align='right'>*Forum ID: </td>
  92. <td><input type="text" name="uid" size="5" maxlength='5' /></td>
  93. </tr>
  94. <tr>
  95. <td align='right'>*Rank:</td>
  96. <td> <select size="1" name="rank">
  97. <?php
  98. foreach($rank_array as $key => $value){
  99. echo("<option value='$key'>$key - $value</option>
  100. ");
  101. }
  102. ?>
  103. </select></td>
  104. </tr>
  105. <tr>
  106. <td align='right'>*Game:</td>
  107. <td>
  108. <select size="1" name="game">
  109. <option>Starcraft</option>
  110. <option>Brood War</option>
  111. <option>Starcraft & Brood War</option>
  112. <option>Warcraft II</option>
  113. <option>Warcraft III</option>
  114. <option>World of Warcraft</option>
  115. <option>Diablo</option>
  116. <option>Diablo II & Expansion</option>
  117. </select></td>
  118. </tr>
  119. <tr>
  120. <td align='right'>AIM:</td><td><input type='text' name='aim' value='none'></td>
  121. </tr>
  122. <tr>
  123. <td align='right'>MSN:</td><td><input type='text' name='msn' value='none'></td>
  124. </tr>
  125. <tr>
  126. <td align='right'>Yahoo:</td><td><input type='text' name='yahoo' value='none'></td>
  127. </tr>
  128. <tr>
  129. <td align='right'>E-Mail:</td><td><input type='text' name='email' value='none'></td>
  130. </tr>
  131. <tr>
  132. <td align='right'>*Date Joined :</td><td>
  133. <select name='date_month'>
  134. <option value='1'>01</option>
  135. <option value='2'>02</option>
  136. <option value='3'>03</option>
  137. <option value='4'>04</option>
  138. <option value='5'>05</option>
  139. <option value='6'>06</option>
  140. <option value='7'>07</option>
  141. <option value='8'>08</option>
  142. <option value='9'>09</option>
  143. <option value='10'>10</option>
  144. <option value='11'>11</option>
  145. <option value='12'>12</option>
  146. </select>
  147. <select name='date_day'>
  148. <option value='1'>01</option>
  149. <option value='2'>02</option>
  150. <option value='3'>03</option>
  151. <option value='4'>04</option>
  152. <option value='5'>05</option>
  153. <option value='6'>06</option>
  154. <option value='7'>07</option>
  155. <option value='8'>08</option>
  156. <option value='9'>09</option>
  157. <option value='10'>10</option>
  158. <option value='11'>11</option>
  159. <option value='12'>12</option>
  160. <option value='13'>13</option>
  161. <option value='14'>14</option>
  162. <option value='15'>15</option>
  163. <option value='16'>16</option>
  164. <option value='17'>17</option>
  165. <option value='18'>18</option>
  166. <option value='19'>19</option>
  167. <option value='20'>20</option>
  168. <option value='21'>21</option>
  169. <option value='22'>22</option>
  170. <option value='23'>23</option>
  171. <option value='24'>24</option>
  172. <option value='25'>25</option>
  173. <option value='26'>26</option>
  174. <option value='27'>27</option>
  175. <option value='28'>28</option>
  176. <option value='29'>29</option>
  177. <option value='30'>30</option>
  178. <option value='31'>31</option>
  179. </select>
  180. <select name='date_year'>
  181. <option value='07'>2007</option>
  182. <option value='08'>2008</option>
  183. <option value='09'>2009</option>
  184. <option value='10'>2010</option>
  185. </select> <i>(mm/dd/yyyy)</i>
  186. </td>
  187. </tr>
  188. <tr>
  189. <td colspan="2">
  190. <p align="center">
  191. <input type="submit" value="Add Member" />
  192. </td>
  193. </tr>
  194. </table>
  195. </form>
  196. </div>
  197. <br/>
  198. Edit Members: (<a href='#' onclick='document.getElementById("edit").style.display = "block"; return false;'>Show</a> / <a href='#' onclick='document.getElementById("edit").style.display = "none"; return false;'>Hide</a>)<br/>
  199. <div style='display: <?php if($_POST['do'] == "edit"){echo("block");}else{echo("none");}?>;' id='edit'>
  200. <?php
  201. if($_POST['do'] == "edit"){
  202. $user_row = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE id = $_POST[uid];"));
  203. $rank_out = $user_row[rank];
  204. $username = mysql_fetch_row(mysql_query("SELECT username FROM forum_users WHERE id = $user_row[uid] LIMIT 1;"));
  205. echo ("<br/>
  206. <table width=\"500\">
  207. <tr><td>
  208. <form action=\"edit.php\" method=\"post\">
  209. <font size='+2'><b>Editing: $username[0]</b></font><br/>
  210. Rank:<select size=\"1\" name=\"rank\">
  211. <option value='$user_row[rank]'>$rank_out - $rank_array[$rank_out]</option>");
  212. foreach($rank_array as $key => $value){
  213. echo("<option value='$key'>$key - $value</option>
  214. ");}
  215. echo("</select><br/>
  216. Game: <select size=\"1\" name=\"game\">
  217. <option>$user_row[game]</option>
  218. <option>Starcraft</option>
  219. <option>Brood War</option>
  220. <option>Starcraft & Brood War</option>
  221. <option>Warcraft II</option>
  222. <option>Warcraft III</option>
  223. <option>World of Warcraft</option>
  224. <option>Diablo</option>
  225. <option>Diablo II & Expansion</option>
  226. </select><br/>
  227. AIM: <input type='text' name='aim' value='$user_row[aim]'><br/>
  228. MSN: <input type='text' name='msn' value='$user_row[msn]'><br/>
  229. Yahoo: <input type='text' name='yahoo' value='$user_row[yahoo]'><br/>
  230. E-Mail: <input type='text' name='email' value='$user_row[email]'><br/>
  231. Date Joined: NON-EDITABLE ATM (Sorry)<br/>
  232. <input type='hidden' name='date_joined' value='$user_row[date_joined]'>
  233. <input type='hidden' name='' value='$user_row[show_aim]'>
  234. <input type='hidden' name='' value='$user_row[show_msn]'>
  235. <input type='hidden' name='' value='$user_row[show_yahoo]'>
  236. <input type='hidden' name='' value='$user_row[show_email]'>
  237. <input type='hidden' name='' value='$user_row[show_date_recruited]'>
  238. <input type='hidden' name='uid' value='$_POST[uid]'>
  239. <input type='hidden' name='do' value='edit'>
  240. <input type='submit' value='Edit Member'>
  241. </form>
  242. </td></tr>
  243. </table>
  244. ");}
  245. ?>
  246. <table width="500">
  247. <tr><td>
  248. Select a member to Edit.<br />
  249. <form action="edit_members.php" method="post">
  250. *Member<br/>
  251. <select name='uid' style=text-align:center;
  252. <option value="0">*Select*</option>
  253. <?php
  254. $results = mysql_query("SELECT * FROM members;");
  255. while($row = mysql_fetch_array($results)){
  256. $username = mysql_fetch_row(mysql_query("SELECT username FROM forum_users WHERE id = $row[uid] LIMIT 1;"));
  257. echo("<option value='$row[id]'>$username[0]</option>
  258. ");
  259. }
  260. ?>
  261. </select><br/>
  262. <input type='hidden' name='do' value='edit'>
  263. <input type='submit' value='Edit Member'>
  264. </form>
  265. </td></tr>
  266. </table>
  267. </div>
  268. Toggle Display: (<a href='#' onclick='document.getElementById("tog").style.display = "block"; return false;'>Show</a> / <a href='#' onclick='document.getElementById("tog").style.display = "none"; return false;'>Hide</a>)<br/>
  269. <div style='display: none;' id='tog'>
  270. <p>Options for toggling the display option of members currently in the database.<br />
  271. <table width="500">
  272. <tr><td>
  273. <form action="edit.php" method="post">
  274. <div align="center">
  275. <table border="0" width="250" cellspacing="0" cellpadding="0" id="table1">
  276. <tr>
  277. <td colspan='2' align='center'>
  278. Displayed Members<br/>
  279. <select name="uid" style="text-align:center;">
  280. <option value="0">*Select*</option>
  281. <?php
  282. $results = mysql_query("SELECT * FROM members WHERE display = \"1\";");
  283. while($row = mysql_fetch_array($results)){
  284. $username = mysql_fetch_row(mysql_query("SELECT username FROM forum_users WHERE id = $row[uid] LIMIT 1;"));
  285. echo("<option value='$row[id]'>$username[0]</option>
  286. ");
  287. }
  288. ?>
  289. </select><br/><br/>
  290. <input type='hidden' name='do' value='off' />
  291. <input type="submit" value="Turn Off Display" />
  292. </td>
  293. </tr></table>
  294. </div>
  295. </form>
  296. </td>
  297. <td>
  298. <form action="edit.php" method="post">
  299. <div align="center">
  300. <table border="0" width="250" cellspacing="0" cellpadding="0" id="table1">
  301. <tr>
  302. <td colspan='2' align='center'>
  303. Hidden Members<br/>
  304. <select name="uid" style="text-align:center;">
  305. <option value="0">*Select*</option>
  306. <?php
  307. $results = mysql_query("SELECT * FROM members WHERE display = \"0\";");
  308. while($row = mysql_fetch_array($results)){
  309. $username = mysql_fetch_row(mysql_query("SELECT username FROM forum_users WHERE id = $row[uid] LIMIT 1;"));
  310. echo("<option value='$row[id]'>$username[0]</option>
  311. ");
  312. }
  313. ?>
  314. </select><br/><br/>
  315. <input type='hidden' name='do' value='on' />
  316. <input type="submit" value="Turn On Display" /></td>
  317. </tr></table></div>
  318. </form>
  319. </td></tr>
  320. </table>
  321. </div>
  322. Delete Members: (<a href='#' onclick='document.getElementById("del").style.display = "block"; return false;'>Show</a> / <a href='#' onclick='document.getElementById("del").style.display = "none"; return false;'>Hide</a>)<br/>
  323. <div style='display: none;' id='del'>
  324. <p>Deleting a member removes their information permanently. If you don't mean to remove all their info use edit, or the display toggle, to peform your task.<br />
  325. <table width="500">
  326. <tr><td colspan='2' align='center'>
  327. <form action="edit.php" method="post">
  328. *Member<br/>
  329. <select name='uid' style="text-align:center;">
  330. <option value="0">*Select*</option>
  331. <?php
  332. $results = mysql_query("SELECT * FROM members;");
  333. while($row = mysql_fetch_array($results)){
  334. $username = mysql_fetch_row(mysql_query("SELECT username FROM forum_users WHERE id = $row[uid] LIMIT 1;"));
  335. echo("<option value='$row[id]'>$username[0]</option>
  336. ");
  337. }
  338. ?>
  339. </select><br/>
  340. <input type='hidden' name='do' value='del'>
  341. <input type='submit' value='Permanent Deletion'>
  342. </form>
  343. </td></tr>
  344. </table>
  345. </div>
  346. </blockquote></td>
  347. <td valign="top" width="20%" class="right"><?php include '../f/include/user/right.php'; ?></td>
  348. </tr>
  349. <tr>
  350. <td class="left"><?php include '../f/include/user/bot-left.php'; ?></td>
  351. <td class="middle"><?php include '../f/include/user/bottom-mid.php'; ?></td>
  352. <td class="right"><?php include '../f/include/user/bot-right.php'; ?></td>
  353. </tr>
  354. <tr>
  355. <td colspan="3">
  356. <img src="../img/footer.png" border="0" height="30px" width="100%" /></td>
  357. </tr>
  358. </table>
  359.  
  360.  
  361. </body>
  362.  
  363. </html>
  364.  

This is the code to the insert.php that handles the data sent from that page.

  1. <?php
  2. require("auth.php");
  3.  
  4. @include '../f/fileid.php'; //config file
  5. $connect = mysql_connect($db_host,$db_username,$db_password);
  6. if (!$connect) {
  7. die('Could not connect: ' . mysql_error());
  8. }
  9. mysql_select_db($db_name)or die ("no select");
  10. $date = mktime(0,0,0,$_POST[date_month],$_POST[date_day],$_POST[date_year]);
  11. $insert="INSERT INTO members (`id` ,`uid` ,`rank` ,`game` ,`show_game` ,`aim` ,`show_aim` ,`msn` ,`show_msn` ,`yahoo` ,`show_yahoo` ,`email` ,`show_email` ,`date_joined` ,`show_date_joined` ,`display`)VALUES (NULL , '$_POST[uid]', '$_POST[rank]', '$_POST[game]', '0', '$_POST[aim]', '0', '$_POST[msn]', '0', '$_POST[yahoo]', '0', '$_POST[email]', '0', '$date', '1', '1');";
  12. if (!mysql_query($insert,$sql)) { die('Error: ' . mysql_error()); }
  13. mysql_close($sql)?>

Any help would be appreciated. I know my code is sloppy I looked around at the other people who posted this error. Tried what was discussed, didn't work. So now I'm posting my own. I have made a successful connection to the database so it isn't due that that.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,746
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource

 
0
  #2
Mar 20th, 2008
Check your query. Print it out and execute it in phpmyadmin /mysql. Maybe the query is wrong. And, what is $sql in insert.php ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource

 
0
  #3
Mar 20th, 2008
You can also download MySQL Query Browser to debug this. That will be a good approach.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC