mysql connecting questions -newbie be warned

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

Post Reply
LittleBill
Forum Newbie
Posts: 12
Joined: Wed Jan 26, 2005 10:42 pm

mysql connecting questions -newbie be warned

Post 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?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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?
LittleBill
Forum Newbie
Posts: 12
Joined: Wed Jan 26, 2005 10:42 pm

Post 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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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
LittleBill
Forum Newbie
Posts: 12
Joined: Wed Jan 26, 2005 10:42 pm

Post 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
LittleBill
Forum Newbie
Posts: 12
Joined: Wed Jan 26, 2005 10:42 pm

Post 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&#1111;'email'] ;
  $message = $_REQUEST&#1111;'message'] ;
  $fname = $_REQUEST&#1111;'fname'] ;
  $lname = $_REQUEST&#1111;'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!
LittleBill
Forum Newbie
Posts: 12
Joined: Wed Jan 26, 2005 10:42 pm

Post by LittleBill »

i apologize, i understand the code tags now, sorry im on 11 forums, never seen that feature before thank you feyd
Post Reply