(see below)
-----Original Message-----
From: Arena Servers [mailto:[EMAIL PROTECTED]
Sent: Friday, August 03, 2007 10:44 AM
To: [email protected]
Subject: [PHP-DB] Store more than 1 piece of information in a single
variable
ok, firstly here's my script...
<?php
$db_host = '*****';
$db_user = '*****';
$db_pass = '*****';
$db_name = '*****';
$db_name2 = '*****';
$time = time();
$conn = mysql_connect($db_host, $db_user, $db_pass);
//N/A - Add $ in front of mysql_select_db and (maybe not necessary) specify
connection
$mysql_select_db($db_name, $conn);
//N/A - No ' needed.
$query = "SELECT * FROM clanmembers";
//N/A - Specify connection in query (maybe not necessary)
$result = mysql_query($query, $conn) or die('Query failed. ' .
mysql_error());
//N/A - I think mysql_fetch_assoc brings the result in with keys;
mysql_fetch_array would let you reference by indices.
while ($row = mysql_fetch_assoc($result))
//N/A - Toss names in an array; otherwise, you're overwriting each username
every time you fetch.
$user_loginname[] = $row['user_loginname'];
//N/A - Maybe not necessary to close DB in between queries.
mysql_close_db;
mysql_select_db($db_name2);
//N/A - Again, no ' needed. Also, your query should recursively check each
username from above.
foreach($user_loginname As $msguser)
{
$query = "SELECT user_id FROM e107_user WHERE user_loginname =
'$msguser'";
$result = mysql_query($query, $conn) or die('Query 2 failed. ' .
mysql_error());
//N/A - We'll use mysql_fetch_assoc() instead, and an if statement.
if($row = mysql_fetch_assoc($result)
{
$user_id = ($row['user_id']);
//N/A - Put code to message user here
}
}
?>
Now, the script's task is to select loginnames from one database1, compare
them to database2, select the user_id associated with the loginnames in
database2 and send a private message to each of those loginnames.
Just now, the script selects only the last loginname from database1 and then
sends a private message to that 1 person.
I need it to select all the loginnames which currently there are 25. So what
do I need to change for this to work?
Thanks in advance.
Paul
Arena Servers - Web Hosting
http://www.arenasmithster.co.uk
-----End Original Message-----
Comments are in original message. I hope at least some of them help.
-- N/A
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php