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

Reply

Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

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

 
0
  #1
Apr 29th, 2007
I keep getting some weird errors in this script:
errors:
 Warning:  mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 86

Warning:  mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 87

Warning:  mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 90

Warning:  mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 92

Warning:  mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 149

Warning:  mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/ikhelper.freehostia.com/globinc/loginfunc.php on line 150
and the script:


  1. <?php
  2.  
  3. function show_login_form($username,$password,$regcode)
  4. {
  5. ?>
  6. <h1>Login</h1>
  7.  
  8. <p>
  9. Login by typing your username and password into
  10. the boxes below and clicking on the 'Login' button.
  11. Your username must match your IK account username <b>exactly</b>
  12. and the password <b>must be different</b>.
  13. </p>
  14.  
  15. <form action="login.php" method="post">
  16. <table border=0 cellpadding=0 cellspacing=0>
  17. <tr>
  18. <td align="right">Username:
  19. <Input type=text name=username value="<?echo stripslashes($username)?>" class=textinput>
  20. </td>
  21. </tr>
  22.  
  23. <tr>
  24. <td align="right">Password:
  25. <Input type=password name=password value="" class=textinput>
  26. </td>
  27. </tr>
  28.  
  29. <tr>
  30. <td>&nbsp;</td>
  31. </tr>
  32.  
  33. <tr>
  34. <td align="right">
  35. <input type=submit name=submit value="Login">
  36. </td>
  37. </tr>
  38. </table>
  39.  
  40. <p>
  41. If you do not have an account, please click <a href="register.php">here</a>
  42. to register an account, or if you have a registration code, enter it here:
  43. <input type=text name=regcode size=5 value="<?echo stripslashes($regcode);?>" class=textinput>.
  44. </p>
  45.  
  46. </form>
  47. <?
  48. }
  49.  
  50. function prepare_failed_alert($failedattempts)
  51. {
  52. if ($failedattempts == 1)
  53. {
  54. $string = "Warning, there has been a failed attempt ";
  55. }
  56. else
  57. {
  58. $string = "Warning, there have been $failedattempts failed attempts ";
  59. }
  60. $string .= "to log into your account.";
  61.  
  62. $_SESSION['head_message'] .= $string;
  63. }
  64.  
  65. function process_groups()
  66. {
  67. // now we'll get the group memberships
  68. $groups="groupfileeveryone";
  69.  
  70. // set the session variables for the groups you want to check. If found it will
  71. // contain a positive number, if not, it will contain FALSE and the existance of
  72. // it can be checked with:
  73. //
  74. // if ($_SESSION["variable"])
  75. //
  76. $_SESSION['group_all']=strpos($groups,"everyone");
  77. }
  78.  
  79. function authenticate($username,$password,$regcode)
  80. {
  81. require_once ("usersql.php");
  82.  
  83. $loginwhere=$_SERVER['REMOTE_ADDR'];
  84. $loginwhen=date("Y/m/d H:i:s",time());
  85.  
  86. $loginconn=mysql_connect($userhost,$useruser,$userpass);
  87. mysql_select_db($userdb,$loginconn);
  88.  
  89. $query="SELECT * FROM $usertable WHERE username='$username' AND password='$password'";
  90. $result=mysql_query($query,$loginconn);
  91.  
  92. if(mysql_num_rows($result))
  93. {
  94. $loginrow=mysql_fetch_array($result);
  95. $failedattempts=$loginrow['failedattempts'];
  96. $dbregcode=$loginrow['userreqcode'];
  97. if ($dbregcode=="")
  98. {
  99. $query="UPDATE $usertable SET lastloginwhere='$loginwhere', failedattempts='0',
  100. lastloginwhen='$loginwhen' WHERE username='$username'";
  101. $result=mysql_query($query,$loginconn);
  102. $_SESSION['username']=$myrow['username'];
  103.  
  104. process_groups();
  105.  
  106. if ($failedattempts > 0)
  107. {
  108. prepare_failed_alert($failedattempts);
  109. }
  110.  
  111. if ($regcode != "")
  112. {
  113. $_SESSION['alert'] .= "You don't need to enter the registration code any more";
  114. }
  115. return true;
  116. } // end if dbregcode is empty
  117. else
  118. {
  119. if ($dbregcode == $regcode)
  120. {
  121. $query="UPDATE $usertable SET userreqcode='', lastloginwhere='$loginwhere',
  122. active='1', useractivated='$loginwhen', failedattempts='0',
  123. lastloginwhen='$loginwhen' WHERE username='$username'";
  124. $result=mysql_query($query,$loginconn);
  125.  
  126. if ($failedattempts > 0)
  127. {
  128. prepare_failed_alert($failedattempts);
  129. } // end failed attempts
  130.  
  131. $_SESSION['username']=$myrow['username'];
  132.  
  133. process_groups();
  134.  
  135.  
  136. return true;
  137. } // end if the regcode matched
  138. else
  139. {
  140. $_SESSION['alert'] = "You need to enter the registration code as well";
  141. return false;
  142. } // end if the regcode didn't match
  143. } // end else not empty
  144. }
  145. else
  146. {
  147. // let's see if the username was valid
  148. $query="SELECT * FROM $usertable WHERE username='$username'";
  149. $result=mysql_query($query,$loginconn);
  150. if(mysql_num_rows($result))
  151. {
  152. $loginrow=mysql_fetch_array($result);
  153. $failedattempts=$loginrow['failedattempts'];
  154. $failedattempts++;
  155. $query="UPDATE $usertable SET failedattempts='$failedattempts'
  156. WHERE username='$username'";
  157. $result=mysql_query($query,$loginconn);
  158. } // end if we found a valid username
  159.  
  160. $_SESSION['alert'] = "Invalid Username and Password, please try again";
  161. return false;
  162. }
  163. }
  164. ?>

whats the problem?

thanks!
Last edited by tomf; Apr 29th, 2007 at 5:47 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 8
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

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

 
0
  #2
Apr 30th, 2007
looks like the problem is not in the code it self but in configurration
the first error about the mysql connection socket
you should check mysql for the socket and check that it is the same one used in php.ini
Last edited by w_3rabi; Apr 30th, 2007 at 6:46 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

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

 
0
  #3
Apr 30th, 2007
Im new to PHP, and im using a free web hosting service.
What socket should it be, and how can i find the PHP.ini?
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 8
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

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

 
0
  #4
Apr 30th, 2007
you should check the hosting company for mysql and php settings and it looks the error is not in your code it is just in server configuration
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

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

 
0
  #5
Apr 30th, 2007
Ok, thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 8
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

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

 
0
  #6
Apr 30th, 2007
anytime dude
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

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

 
0
  #7
May 2nd, 2007
Originally Posted by w_3rabi View Post
anytime dude
How do i change the settings in my script?
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 8
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

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

 
0
  #8
May 3rd, 2007
you could use [php]ini_set()[/php]
but i advice you to contact the server administrator
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 1
Reputation: shundeep is an unknown quantity at this point 
Solved Threads: 0
shundeep shundeep is offline Offline
Newbie Poster

correct query

 
0
  #9
9 Days Ago
<?php
if(isset($_FILES['file']))
{
if ((($_FILES[
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC