Page 2 of 2

Posted: Sun Jun 10, 2007 12:39 pm
by thefreebielife
okay this is my edited version now:

Code: Select all

<? session_start(); ?>
<? require("config.php"); require("functions.php"); admin(); ?>
<!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=ISO-8859-1" />
<title>Untitled Document</title>
</head>

<?php
$sql = mysql_connect('mysql.powweb.com', 'cash1', 'cash');
if (!$sql) {
    die('Could not connect: ' . mysql_error());
?>

<table style="border:1px solid #0099CC; width:735px; font-size:12px; margin-left:30px;" cellpadding="2" cellspacing="0">
	<tr>
	<td colspan="3" style="border-bottom:1px solid #0099CC"><div align="center"><strong>Your Manual Credit Requests </strong></div></td>
	</tr>
	<tr bgcolor="#CCEAEA">
	<td width="25%" style="border-bottom:1px solid #0099CC"><div align="center">uId </div></td>
	<td width="50%" style="border-bottom:1px solid #0099CC"><div align="center">Name</div></td>
	<td width="25%" style="border-bottom:1px solid #0099CC"><div align="center">email</div></td>
	</tr>

	<?   
	$sql = SELECT username FROM cash1.users WHERE uId = "" SELECT username FROM a100.users WHERE uId = "" . "'order by uId DESC, username DESC";
	$result = mysql_query($sql) or die(mysql_error());
	$i=0;
	while($r=mysql_fetch_array($result))
	{	
		$i=$i+1;
		?>
		<tr bgcolor="#<?= ($i++%2) ? 'FFFFFF' : 'F5F5F5' ?>">
		<td width="25%" style="border-bottom:1px dashed orange; border-right:1px dashed orange"><div align="center"><FONT SIZE="2"><? echo $r["uId"]; ?></FONT></div></td>
		<td width="50%" style="border-bottom:1px dashed orange; border-right:1px dashed orange"><div align="left"><FONT SIZE="2">&nbsp;<? echo $r["username"]; ?></FONT></div></td>
		<td width="25%" style="border-bottom:1px dashed orange; border-right:1px dashed orange"><div align="center"><FONT SIZE="2"><? echo $r["email"]; ?></FONT></div></td>
		</tr>  
		<? } 
	if($i==0)
	{
		?>
		<tr>
		<Td colspan=3 align="center"><FONT SIZE="2" COLOR="#FF0000"><B>There are no manual credit requests submitted.</B></FONT></Td>
		</tr>

		<? } ?>


	</table>	

<body>
</body>
</html>
But now im getting these 2 errors:
/hermes/web10/b257/pow.thefreebielife/cash/htdocs/test1.php on line 24
PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'freebie'@'cgi1502.int.bizland.net' (using password: YES) in /hermes/web10/b257/pow.thefreebielife/htdocs/config.php on line 6
The second one is most confusing since im not even using the "freebie" login anymore

This is my config file:

Is this not formated correctly and is whats causing the errors?

Code: Select all

<?

$user="cash1" else if "a100";
$password="cash" else if "a100";
$database="cash1";
mysql_connect("mysql14.powweb.com",$user,$password) or die("Could not insert data because ".mysql_error());
@mysql_select_db($database) or die("Could not insert data because ".mysql_error());

?>

Posted: Sun Jun 10, 2007 12:58 pm
by Benjamin
There are quite a few things wrong with your code. The error doesn't correspond to the user and pass you have entered.

This code is not right at all.

Code: Select all

$user="cash1" else if "a100";
$password="cash" else if "a100";
Also, you can only run 1 database query at a time. You have two in your $sql variable.

You must have another connection someplace being included or your not posting all your code.

I would encourage you to go to php.net and review the code samples in the manual for the functions you are using. Such as mysql_query, mysql_connect etc.

Posted: Sun Jun 10, 2007 2:50 pm
by volka
And why do you have
<?php
$sql = mysql_connect('mysql.powweb.com', 'cash1', 'cash');
if (!$sql) {
die('Could not connect: ' . mysql_error());
?>
in your main script when you already included a script that is supposed to establish a database connection?
Please think about what each function call in your scripts does, about when and why it is needed and what happens in case of success/failure.