Page 1 of 1
mysql connecting questions -newbie be warned
Posted: Fri Jan 28, 2005 12:14 am
by LittleBill
ok trying to connect to mysql db, i got it working but have some questions
this is on a xp box
i am running mysql 4.1.7
i am running apache 1.3
i am running php 4.3.1 for win
i was getting an authentication error, and i was reading this due to the new password algorithm in mysql 4.1 and was told to use
SET PASSWORD FOR 'test'@'%' = OLD_PASSWORD('1234'); at the sql prompt
this allowed me in the db, but my question
i was reading that having the new version of php, which i thought i had, i would not have to use the above coding to get it too work, i would like to use the new hashing, and not have to manually input this code for everyuser, could someone explain in newbie terms how to fix this problem?
Posted: Fri Jan 28, 2005 12:28 am
by shiznatix
well ok. if
your trying to connect to a db through php
you would actually use somtin like
Code: Select all
$dbhost = 'localhost';
$dbusername = ****';
$dbpassword = '****';
$dbname = '****';
$connect = mysql_connect($dbhost, $dbusername, $dbpassword) or die ('Cant connect to MySQL');
mysql_select_db($dbname,$connect) or die ("Could not select database");
try
something like that?
Posted: Fri Jan 28, 2005 12:44 am
by LittleBill
this what i have
<html>
<head><title>Connect Server</title></head>
<body>
<?
$link = mysql_connect("211.102.211.21:3306","test","1234")or die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_select_db(php , $link)
or die("Couldn't open $db: ".mysql_error());
print "Successfully connected to db.\n";
mysql_query ("INSERT INTO data (number ) VALUES ('21')");
print "Successfully inserted to db.\n";
mysql_close($link);
?>
</body>
</html>
this is what i am using and it is working, although right now after running it once it will not keep adding 21 to the db, its done it only once so im having that issue now, but i still need to figure why i need that set password command i spoke above before, also my /n in my print command is not working, its running the message straight across the page
Posted: Fri Jan 28, 2005 12:52 am
by shiznatix
im not sure what you are tying to do exacltly, and please use the [ code ] tags. explain what your trying to do and post some code
Posted: Fri Jan 28, 2005 12:58 am
by LittleBill
it wasn't letting me add more then one 21 cus it was a primary key, lol i need to get my head on straight
Posted: Fri Jan 28, 2005 1:02 am
by LittleBill
its working well, here is what i have so far
this is a sendmail.php that is running off another form i created
Code: Select all
<?
$email = $_REQUESTї'email'] ;
$message = $_REQUESTї'message'] ;
$fname = $_REQUESTї'fname'] ;
$lname = $_REQUESTї'lname'] ;
mail( "littlebill@littlebill.shacknet.nu", "Feedback Form Results",
" First Name $fname \n Last Name $lname\n $message", "From: $email" );
$link = mysql_connect("211.102.211.21:3306","test","1234")or die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_select_db(php , $link)
or die("Couldn't open $db: ".mysql_error());
print "Successfully connected to db.\n";
mysql_query ("INSERT INTO data (email,first,last,message ) VALUES ('$email','$fname','$lname','$message')");
print "Successfully inserted to db.\n";
mysql_close($link);
?>
feyd | use formatting!
Posted: Fri Jan 28, 2005 1:26 am
by LittleBill
i apologize, i understand the code tags now, sorry im on 11 forums, never seen that feature before thank you feyd