[PHP-DB] Connecting to mysql from another host

2007-08-03 Thread joefazee

I want to connect to a database hosted on another server like from
www.sample.com i want to connect to www.example2.com.what did i need to do?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Connecting-to-mysql-from-another-host-tf4210929.html#a11978401
Sent from the Php - Database mailing list archive at Nabble.com.


[PHP-DB] Re: Connecting to mysql from another host

2007-08-03 Thread David Robley
joefazee wrote:

 
 I want to connect to a database hosted on another server like from
 www.sample.com i want to connect to www.example2.com.what did i need to
 do?
 
 Thanks.

First up you need to ensure that www.example2.com a) allows remote
connections and b) has privileges for [EMAIL PROTECTED]



Cheers
-- 
David Robley

Why doesn't the Bat Computer ever crash?
Today is Setting Orange, the 69th day of Confusion in the YOLD 3173. 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Store more than 1 piece of information in a single variable

2007-08-03 Thread Arena Servers
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);

mysql_select_db($db_name);

$query = SELECT * FROM `clanmembers`;

$result = mysql_query($query) or die('Query failed. ' . mysql_error());

while ($row = mysql_fetch_array($result)){

$user_loginname = $row['user_loginname'];

}

mysql_close_db;

mysql_select_db($db_name2);

$query = SELECT user_id FROM `e107_user` WHERE `user_loginname` = 
'$user_loginname';

$result = mysql_query($query) or die('Query 2 failed. ' . mysql_error());

while ($row = mysql_fetch_array($result)){

$user_id = ($row['user_id']);

$query = 'INSERT INTO e107_private_msg VALUES (NULL, \'1\', \''.$user_id.'\', 
\''.$time.'\', \'0\', \'Clan War 2\', \'Clan War Arranged\', \'0\', \'0\', 
\'\', \'+rr+\', \'0\');';

$result = mysql_query($query) or die('Query 3 failed. ' . mysql_error());

}

?


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

Re: [PHP-DB] Store more than 1 piece of information in a single variable

2007-08-03 Thread Michael Preslar
First.. You're using mysql_fetch_array when you wanted
mysql_fetch_assoc.. .. select user_id from whatever .. and then $row =
mysql_fetch_array($res) .. youd have a $row[0].. mysql_fetch_assoc
would allow $row['user_id']

Secondly.. You can use one query to select all the info..

select e107.user_id FROM db2.e107_user as e107 left join
db1.clanmembers as clan on e107.user_loginname = clan.user_loginname

You'll still want to mysql_select_db($db2) for your insert query

Thirdly.. I'd change the insert query to:

$user_id = mysql_real_escape_string($user_id);
$query = INSERT INTO e107_private_msg VALUES (NULL, '1', '$user_id',
NOW(), '0', 'Clan War 2', 'Clan War Arranged', '0', '0', '', '+rr+',
'0');
mysql_query($query) or die('Query 3 failed. ' . mysql_error());

Where the entire query is surrounded by double quotes, so you dont
have to back slash singles.. $user_id is escaped, so its safe.. using
mysql's NOW() function instead of php's time()..

On 8/3/07, Arena Servers [EMAIL PROTECTED] wrote:
 mysql_select_db($db_name2);

 $query = SELECT user_id FROM `e107_user` WHERE `user_loginname` = 
 '$user_loginname';

 $result = mysql_query($query) or die('Query 2 failed. ' . mysql_error());

 while ($row = mysql_fetch_array($result)){

 $user_id = ($row['user_id']);

 $query = 'INSERT INTO e107_private_msg VALUES (NULL, \'1\', \''.$user_id.'\', 
 \''.$time.'\', \'0\', \'Clan War 2\', \'Clan War Arranged\', \'0\', \'0\', 
 \'\', \'+rr+\', \'0\');';

 $result = mysql_query($query) or die('Query 3 failed. ' . mysql_error());

 }

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Store more than 1 piece of information in a single variable

2007-08-03 Thread Uber Wannabe

(see below)

-Original Message-
From: Arena Servers [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 03, 2007 10:44 AM
To: php-db@lists.php.net
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



Re: [PHP-DB] Connecting to mysql from another host

2007-08-03 Thread Goltsios Theodore
Well you it depends on what method you use to access mysql. If for 
instance if you use PDO you could do something like that to  connect and 
query:

?php

 $dbhost = 'remote_hostname';
 $dbuser = 'mysql_username';
 $dbpass = 'mypass';
 $db = 'database_to_use';

 $db_handler  = new PDO('mysql:host='.$dbhost.';dbname='.$db, $dbuser, 
$dbpass);


$query = SELECT id, fname, lname FROM users WHERE id'1';
$st_handler  = $db_handler-prepare($query);
$st_handler-execute();

?

Have in mind that you must have installed the PDO mysql modules using 
pear for this method to work. There are other methods like this one:

http://www.php-mysql-tutorial.com/connect-to-mysql-using-php.php

Have fun,

Theodoros Goltsios
Kinetix Tele.com Support Center
email: [EMAIL PROTECTED], [EMAIL PROTECTED]
Tel.  Fax: +30 2310556134
WWW: http://www.kinetix.gr/



joefazee wrote:

I want to connect to a database hosted on another server like from
www.sample.com i want to connect to www.example2.com.what did i need to do?

Thanks.
  


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: PHP ORACLE SSL ?

2007-08-03 Thread Roberto Mansfield
Narasimha Gangaiah wrote:
 Greetings,
 
 I am writing a web application using PHP. I want to use PEAR::DB to connect
 to user database.
 I want the connection to be secured using SSL.
 
 Does oci8.sl (php oracle dblibrary) support SSL connection to Oracle Server
 ? 
 
 I know we can securely connect to MYSQL server using PEAR::DB  SSL. 
 Is it possible to estable secure connection to oracle server using PHP ?
 
 Best Regards
 Simha
 

You may also want to consider using stunnel to encrypt your oracle traffic.

-Roberto

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Store more than 1 piece of information in a single variable

2007-08-03 Thread Niel
 First.. You're using mysql_fetch_array when you wanted
 mysql_fetch_assoc.. .. select user_id from whatever .. and then $row =
 mysql_fetch_array($res) .. youd have a $row[0].. mysql_fetch_assoc
 would allow $row['user_id']

 mysql_fetch_array($res) will fetch both associative and numerical
indexes, so it will have  $row[0] and $row['user_id'] in it. It has an
optional second parameter to indicate associative, numerical or both,
defaulting to both.  mysql_fetch_row only fetches numerically indexed
arrays

--
Niel Archer

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP-DB] Store more than 1 piece of information in a single variable

2007-08-03 Thread juanjo
El mensaje ha llegado correctamente pero... estoy de vacaciones hasta el 
próximo 20 de Agosto. Atenderé tu correo a la vuelta. Si por el motivo que 
fuere necesitas ponerte en contacto con ADIMEDIA puedes hacerlo en [EMAIL 
PROTECTED] o en el Telf. 934 63 57 37.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] PHP ORACLE SSL ?

2007-08-03 Thread Christopher Jones


Narasimha Gangaiah wrote:
 Greetings,

 I am writing a web application using PHP. I want to use PEAR::DB to connect
 to user database.
 I want the connection to be secured using SSL.

 Does oci8.sl (php oracle dblibrary) support SSL connection to Oracle Server
 ?

 I know we can securely connect to MYSQL server using PEAR::DB  SSL.
 Is it possible to estable secure connection to oracle server using PHP ?

 Best Regards
 Simha


The network protocols used by Oracle can encrypt and/or checksum data
transfers between Oracle library calls in PHP's oci8 extension and the
database server.

See 
http://download.oracle.com/docs/cd/B12037_01/network.101/b10772/asoconfg.htm#1006342
The useful bits are at the bottom of that page where the sample
sqlnet.ora files are given (just above tables 3-2 and 3-3).  In effect
all you need to do is add a couple of configuration lines and restart
the network listener to get encrypted traffic. Check your license too:
the Advanced Security Option (ASO) is probably a separately licensble
product.

Chris

--
Christopher Jones, Oracle
Email: [EMAIL PROTECTED]Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/   Free PHP Book: http://tinyurl.com/f8jad

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] How to test PHP form for proper input

2007-08-03 Thread Phil Matt
I've got a mail form that automatically pulls in the addressee from a MySQL db, 
and lets the sender
fill in his/her own info before sending. I figured out how to set up tests for 
legal input in the
different fields, but I don't know how to incorporate the test results into my 
form submission code.
(Sorry for the dumb question, but I'm not an experienced PHP coder...)

Here the basic stuff:

//SENDS MAIL
?
if ($submit){
mail($recipient, $subject, $message, From:\$from_name\$from_email\r\n .
Reply-to: $from_email\r\n .   
X-Mailer: PHP/ . phpversion());
echo h1Your message has been sent!/h1;}
?
//FORM USED

form name=mymail id=talign3 method=post action=? $_SERVER['PHP_SELF']; 
?
table class=bg summary=Form for sending email cellspacing=0
tr rowspan=2th colspan=3Send e-mail to: ? $recip=$_GET['recip']; echo 
$recip; ?/th/tr
tr
  td width=23%label for=your nameYour Name/label/td
  td width=77%input name=from_name type=text id=from_name 
value=?=$from_name?
size=45/td
/tr
tr
  td nowraplabel for=email addressYour Email Address/label/td
  td width=70%input name=from_email type=text id=from_email 
value=?=$from_email?
size=45/td
/tr
tr
  tdlabel for=subjectSubject/label/td
  tdinput name=subject type=text id=subject value=?=$subject? 
size=55/td
/tr
tr
td style=vertical-align:topMessage/td
  tdtextarea name=message cols=45 rows=15 
id=message?=$message?/textarea/td
/tr
tr

  tddiv align=right
  input name=userid type=hidden id=userid value=?$to_name? /
  input name=cmd type=hidden id=cmd value=validate_form
  input type=submit name=submit value=send mail
/div/td
/tr
  /table/form

//TESTING CODE
?
  $pattern = '/[EMAIL PROTECTED]/';
  extract($_POST);
  /*validate*/
  function check_from($from_name)
  {
  if(!preg_match(/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\]+$/s,$from_name))
  return TRUE;
  else
  return FALSE;
  }
  function check_email($from_email)
  {
  if (!preg_match($pattern,$from_email))
  return TRUE;
  else
  return FALSE;
  }
  function check_subject($subject)
  {
  if(!preg_match(/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\]+$/s,$from_name))
  return TRUE;
  else
  return FALSE;
  }
  function check_message($message)
  {
  if(!preg_match(/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\]+$/s,$message))
  return TRUE;
  else
  return FALSE;
  }
 /*test fails*/
 $error=0; // check up variable
 /*start*/
 if(!check_from($from_name))
 {
 echo You haven't entered your name in the Name box!;
 $error++; // $error=$error+1;
 }
 if(!check_email($from_email))
 {
 echo You haven't entered a valid email address in the email box!;
 $error++;
 if(!check_subject($subject))
 {
 echo You haven't entered your name in the Name box!;
 $error++;
 if(!check_message($message))
 {
 echo You haven't entered anything in the Message box!;
 $error++;
 }
 if($error==0)
 {echo
 Thank you for your email. You should receive a reply shortly from the staff 
person you contacted;
 } else
 {
 echoNumber of errors: $error;
 }
 ?

TIA for your help!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] PHP ORACLE SSL ?

2007-08-03 Thread Narasimha Gangaiah


Thanks all for your replies. 

So to secure the connection between oracle server and PHP oci8 client, we
have to modify the sqlnet.ora shipped with oracle product ,as suggested by
christopher in his reply, and no API or interface is avaialble to do the
same via PHP .

In the same manual suggested by Chris, I found a link to secure oracle
connection using SSL . (
http://download.oracle.com/docs/cd/B14117_01/network.101/b10772/asossl.htm#1006120).
 



Christopher Jones wrote:
 
 
 Narasimha Gangaiah wrote:
   Greetings,
  
   I am writing a web application using PHP. I want to use PEAR::DB to
 connect
   to user database.
   I want the connection to be secured using SSL.
  
   Does oci8.sl (php oracle dblibrary) support SSL connection to Oracle
 Server
   ?
  
   I know we can securely connect to MYSQL server using PEAR::DB  SSL.
   Is it possible to estable secure connection to oracle server using PHP
 ?
  
   Best Regards
   Simha
  
 
 The network protocols used by Oracle can encrypt and/or checksum data
 transfers between Oracle library calls in PHP's oci8 extension and the
 database server.
 
 See
 http://download.oracle.com/docs/cd/B12037_01/network.101/b10772/asoconfg.htm#1006342
 The useful bits are at the bottom of that page where the sample
 sqlnet.ora files are given (just above tables 3-2 and 3-3).  In effect
 all you need to do is add a couple of configuration lines and restart
 the network listener to get encrypted traffic. Check your license too:
 the Advanced Security Option (ASO) is probably a separately licensble
 product.
 
 Chris
 
 -- 
 Christopher Jones, Oracle
 Email: [EMAIL PROTECTED]Tel:  +1 650 506 8630
 Blog:  http://blogs.oracle.com/opal/   Free PHP Book:
 http://tinyurl.com/f8jad
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PHP-ORACLE-SSL---tf4208442.html#a11991531
Sent from the Php - Database mailing list archive at Nabble.com.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php