Re: [PHP-DB] MySQL connects to localhost via socket reguardless

2005-04-10 Thread Josip Dzolonga
Jeffrey D. Means wrote:
I am trying to connect to a DB on a difrent server but mysql keeps 
connecting to the local server via the socket.  What is going on?
-- code snippet--
$connection = mysql_connect(mysql.meanspc.com:3306, Removed, 
Removed);
Well try some debugging :
   $connection = mysql_connect(...) or die(mysql_error());
What do you get ?
--
Josip Dzolonga
http://josip.dotgeek.org
jdzolonga[at]gmail.com


Re: [PHP-DB] That crazy IF command!

2005-04-03 Thread Josip Dzolonga
Matthew Weier O'Phinney wrote:
 if (strpos($query_holder, big fat)) {
 // found
 }
That's completely wrong. Well try this :
$string = big fat fatty;
if (strpos($string, big fat)) echo 'found';
else echo 'not found';
It will always return false, because strpos in this case returns 0 
(because the searched text is at position 0) so the IF statement will 
never pass. The corrected version of the code above :

if (strpos($string, big fat)!==false) echo 'found';
else echo 'not found';
Regular Expressions are always a better and more elegant solution so 
take a look at www.php.net/preg

These were my 0,02$
--
Josip Dzolonga
http://josip.dotgeek.org
jdzolonga[at]gmail.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] supporting multiple databases...

2005-01-30 Thread Josip Dzolonga
On Sun, 2005-01-30 at 14:42 -0500, Paul Chvostek wrote:
 I'm writing an application which needs to make SQL queries, and I'd like
 to give it support for multiple database servers, starting with MySQL
 and PostgreSQL.

Take a look here http://www.php.net/dbx and here
http://pear.php.net/package/DB . 
-- 
Josip Dzolonga,
dzolonga at mt dot net dot mk

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



Re: [PHP-DB] Hyphens and MySQL

2005-01-28 Thread Josip Dzolonga
On Fri, 2005-01-28 at 14:21 +, Mark Benson wrote:
  Is there an easy way to search and replace/remove characters in a string in 
 PHP?

www.php.net/str_replace , www.php.net/preg_replace . You can strip out
the - characters with str_replace(-, , $string);
-- 
Josip Dzolonga,
dzolonga at mt dot net dot mk

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



Re: [PHP-DB] authenticating users with phpmysql

2005-01-26 Thread Josip Dzolonga
On Wed, 2005-01-26 at 12:44 +0200, it clown wrote: 
$db_user = $_POST[txt_name];
$db_password = $_POST[txt_password];
$db_name = data;
$connection = @mysql_connect ($db_host, $db_user,
 $db_password) or die (error connecting);
echo connection successful!;
 ?

Replace this line
-
$connection = @mysql_connect ($db_host, $db_user, $db_password) or die
(error connecting); 
-
with this one
-
$connection = @mysql_connect($db_host, $db_user, $db_password) or die
(Error connecting :  .mysql_error());
-
so you can debug better. However take a look here
www.php.net/mysql_connect . $db_user and $db_password are the username
and password to log on the MYSQL DATABASE. You probably want to login
from a database table which will contain a password and username field.
Here's an example :

$dbHandle = mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db($db_name);
$sql = SELECT * FROM `table_name` WHERE `user_field` = ' .
$_POST[txt_name] .  ' AND `pass_field` = ' .
md5($_POST[txt_password]) . ' LIMIT 1;
$result = mysql_query($sql, $dbHandle);
if(mysql_num_rows($result)!=0) /* Logged on */
else /* Invalid Username/Password */

There're lots of tutorials out there, google's your friend. 

P.S. This is my first message on this maillist so I want to say hello to
everyone ;-)

-- 
Josip Dzolonga,
dzolonga at mt dot net dot mk

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