![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
RDC
-
Posts
9 -
Joined
-
Last visited
Never
Posts posted by RDC
-
-
did you move the database over as well ?
are the username and password correct ?
what about user name prefixes (if used) was it updated ?
Yes. All that is done.
-
Removing the @ threw up the following:
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'xxxx'@'localhost' (using password: YES) in /home/g/r/sitename/public_html/html/checklogin.php on line 5Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO) in /home/g/r/sitename/public_html/html/checklogin.php on line 7
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/g/r/sitename/public_html/html/checklogin.php on line 7
Warning: mysql_query() [function.mysql-query]: Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO) in /home/g/r/sitename/public_html/html/checklogin.php on line 14
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/g/r/sitename/public_html/html/checklogin.php on line 14
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/g/r/sitename/public_html/html/checklogin.php on line 15
-
I would have done this:
<?php session_start(); @ $db = mysql_pconnect("localhost", "username", "password"); mysql_select_db("databasename",$db); $usernam = $_REQUEST['usernam']; $passwrd = $_REQUEST['passwrd']; $query = "select * from tbllogin where user = '".$usernam."' and pass = '".$passwrd."'"; $result = mysql_query($query); $num_results = mysql_num_rows($result);
I tried this and it didn't work. Thank you for the suggestion. I will remove the @ and report back.
-
Hello,
I have just swapped servers and everything is working fine except for one thing. This code is generating errors.
<?php session_start(); @ $db = mysql_pconnect("localhost", "username", "password"); mysql_select_db("databasename"); $usernam = $_REQUEST['usernam']; $passwrd = $_REQUEST['passwrd']; $query = "select * from tbllogin where user = '".$usernam."' and pass = '".$passwrd."'"; $result = mysql_query($query); $num_results = mysql_num_rows($result);
It is generating the following error when username and password is entered:
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/g/r/sitename/public_html/html/checklogin.php on line 7Warning: mysql_query() [function.mysql-query]: Access denied for user 'UNKNOWN_USER'@'localhost' (using password: NO) in /home/g/r/sitename/public_html/html/checklogin.php on line 14
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/g/r/sitename/public_html/html/checklogin.php on line 14
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/g/r/sitename/public_html/html/checklogin.php on line 15
I am sure it is something really simple, I can't seem to make any headway on it. Would appreciate some help if anyone can.
Thank you.
-
There is another script that allows me to edit users, in particular the type of currency they use. This is displayed as a number from 0-3. This keeps resetting to 0 each time I press the update button. Everything else is working fine except for this, any ideas?
[code]$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . $_SERVER['QUERY_STRING'];
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE users SET username=%s, password=%s, realname=%s, email=%s, currency=%s WHERE initnum=%s",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['realname'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['currency'], "text"),
GetSQLValueString($_POST['initnum'], "int"));
mysql_select_db($database_grey, $grey);
$Result1 = mysql_query($updateSQL, $grey) or die(mysql_error());
$updateGoTo = "supplier.php?msg=ok";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE users SET username=%s, password=%s, realname=%s, email=%s, currency=%s WHERE initnum=%s",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['realname'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['currency'], "text"),
GetSQLValueString($_POST['initnum'], "int"));
mysql_select_db($database_grey, $grey);
$Result1 = mysql_query($updateSQL, $grey) or die(mysql_error());
$updateGoTo = "users.php?msg=ok";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}[/code] -
That appears to have done the trick. Thank you!!
-
[quote author=thorpe link=topic=114762.msg467048#msg467048 date=1163379621]
define what you meen by [i]not doing as its told[/i]. You might also try narrowing the problem down a little, Dreamweaver code is hard enough to read without having to sift through a ton of it.
One problem I see is you dont have $msg defined. Change this....
[code=php:0]
if ($msg == "ok"){
[/code]
to...
[code=php:0]
if ($_GET['msg'] == "ok"){
[/code]
[/quote]
Sorry. I have been getting a little worked up over this and not thinking straight. It just resets the form when submit is pressed. I put all the code in as I wasn't sure what the actual problem was. Thank you for your help, I will change the part that you mentioned and I apologise for just running blindly in and mashing away! I was in a panic. -
PHP was upgraded on my server to PHP 5 and now a script that I had running and working is not doing as it is told. I can't seem to see what the problem is. Can anyone help?
[code]<?php require_once('../Connections/grey.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . $_SERVER['QUERY_STRING'];
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO users (username, password, realname, email, currency) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['realname'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['currency'], "text"));
mysql_select_db($database_grey, $grey);
$Result1 = mysql_query($insertSQL, $grey) or die(mysql_error());
$insertGoTo = "adduser.php?msg=ok";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
echo "<b><font size=2 face=Verdana>User Added Successfully</font></b>";
//header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_grey, $grey);
$query_user = "SELECT * FROM users";
$user = mysql_query($query_user, $grey) or die(mysql_error());
$row_user = mysql_fetch_assoc($user);
$totalRows_user = mysql_num_rows($user);
?>
<html>
<head>
<title>Add User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><font face="Arial, Helvetica, sans-serif" size="2" color="#999999"> </font></p>
<table width="95%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#999999">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="#EEEEEE">
<p><font face="Arial, Helvetica, sans-serif" size="2" color="#999999">
<?php
if ($msg == "ok"){
?>
</font></p>
<p></p>
<table width="90%" border="0" cellspacing="0" cellpadding="4" align="center" height="14">
<tr bgcolor="#003399">
<td width="660" height="11" bgcolor="#CCCCCC"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><strong>Status
Message</strong></font></td>
</tr>
<tr>
<td width="660" height="20" bgcolor="#DDDDDD" class="table_outline">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><strong>OPERATION
SUCCESSFUL </strong><br>
<br>
</font></div></td>
</tr>
</table>
<?php } ?>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Username:</strong></font></td>
<td><input type="text" name="username" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Password:</font></strong></td>
<td><input type="text" name="password" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Real
Name:</font></strong></td>
<td><input type="text" name="realname" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Email:</font></strong></td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Region:</strong></font></td>
<td><select name="currency" id="currency">
<option value="1">US Dollar</option>
<option value="2">Euro</option>
<option value="3">UK Sterling</option>
<option value="0">Scottish Water</option>
<option value="3"><< Select >></option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Add User"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
<p> </p>
</td>
</tr>
</table></td>
</tr>
</table>
<FORM>
<p align="right">
<INPUT name="Button" Type="Button"
onclick="window.close()" Value="Close Window">
</p>
</FORM>
<p> </p>
</body>
</html>
<?php
mysql_free_result($user);
?>[/code]
Swapping server - code problem
in PHP Coding Help
Posted
I have checked and I cannot see any changes in capitalisation. The user has access privileges too.
How annoying. What is the best way to bypass the login as I need this to work?