PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
thefreebielife
Forum Contributor
Posts: 126 Joined: Thu Apr 26, 2007 2:59 pm
Post
by thefreebielife » Sat Jun 09, 2007 10:32 pm
Code: Select all
<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 * FROM cash1.. users, freebie.. users where username='" . $_SESSION['username'] . "' order by status DESC, uId DESC";
$result = mysql_query($sql);
$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"> <? 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 users</B></FONT></Td>
</tr>
<? } ?>
</table>
errors:
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/web10/b257/pow.thefreebielife/cash/htdocs/test1.php on line 23
PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: A link to the server could not be established in /hermes/web10/b257/pow.thefreebielife/cash/htdocs/test1.php on line 21
PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Access denied for user 'wwwuser'@'cgi0702.int.bizland.net' (using password: NO) in
I dont know what to do as im trying to figure out how to access info from 2 db's. any help would be very appriciated
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sat Jun 09, 2007 10:41 pm
change
to
Code: Select all
$result = mysql_query($sql) or die(mysql_error());
For a more informative error
thefreebielife
Forum Contributor
Posts: 126 Joined: Thu Apr 26, 2007 2:59 pm
Post
by thefreebielife » Sat Jun 09, 2007 10:48 pm
Access denied for user 'wwwuser'@'cgi0704.int.bizland.net' (using password: NO)
that comes up on the page
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Jun 09, 2007 11:07 pm
Missing or improper mysql_connect() call? Permissions set appropriately for the user?
thefreebielife
Forum Contributor
Posts: 126 Joined: Thu Apr 26, 2007 2:59 pm
Post
by thefreebielife » Sat Jun 09, 2007 11:10 pm
well i have it so "cash1" can log into "freebie" and "freebie" can log into "cash1"
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Jun 10, 2007 12:37 am
That may be, but MySQL is saying "wwwuser."
thefreebielife
Forum Contributor
Posts: 126 Joined: Thu Apr 26, 2007 2:59 pm
Post
by thefreebielife » Sun Jun 10, 2007 8:20 am
well i dont have a user called "wwwuser" and i have no idea what "cgi0704.int.bizland.net" is
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Jun 10, 2007 8:23 am
Where is your
mysql_connect() call?
thefreebielife
Forum Contributor
Posts: 126 Joined: Thu Apr 26, 2007 2:59 pm
Post
by thefreebielife » Sun Jun 10, 2007 8:27 am
well my config file connects to cash1
but i didnt know how to do that using more then one call?
for example, where would the second db need to go in this code:
Code: Select all
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Jun 10, 2007 9:40 am
mysql_close() closes a mysql connection
Therefore
Code: Select all
$link = mysql_connect(...);
// <- error handling ->
mysql_close($link)doesn't make much sens
thefreebielife
Forum Contributor
Posts: 126 Joined: Thu Apr 26, 2007 2:59 pm
Post
by thefreebielife » Sun Jun 10, 2007 9:41 am
oh well i just found that through the link. but i still dont understand where to put the second connection
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Jun 10, 2007 9:43 am
...second connection ...sorry, I have no idea what you're asking.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sun Jun 10, 2007 10:27 am
You only need one connection. You aren't locked to one database when you connect. You can specify the database in the query.
Code: Select all
SELECT fieldone, fieldtwo FROM database1.table1 WHERE fieldone > 10
thefreebielife
Forum Contributor
Posts: 126 Joined: Thu Apr 26, 2007 2:59 pm
Post
by thefreebielife » Sun Jun 10, 2007 10:31 am
so the would this be right:
Code: Select all
SELECT username FROM cash1.users WHERE uId = ""
SELECT username FROM freebie.users WHERE uId = ""
just like that if i want to use 2 separate db's?
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sun Jun 10, 2007 10:32 am
Yes.