Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New in PHP / MySQL how to Begin 4

Status
Not open for further replies.

Qwark

Programmer
Sep 26, 2000
59
0
0
NL
Hello PHP Boys & Girls,

I like to begin in PHP and connect some things with a MySQL database. What is the best way to begin and of course do you know good site's, manuals or turtorials for that kind of things. I have the MySQL manual and PHP manual already, they are good, but maybe you know some better stuff.

Thanks for all reactions,

Qwark
 
I have only started php + mySQL recently like you but have found these sites a good beginning,


I think asking in the forums can be even more helpfull though!

Hope these help. Chris MacPherson
thedamager@hotmail.com
Bring on the new Browza's!!
 
I believe there is a FAQ on how to do this for the PHP forum.

If not, here is the code to connect to a mySQL database:
[tt]
$dbhost = "localhost"; // your host name here
$dbuser = "username"; // your mysql username
$dbpass = "password"; // your mysql password

$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn) {
print "Failed to connect to database.\n";
} else {
print "Connected to database.\n";
}

[/tt]

In order to insert stuff into a database, you have to know some SQL.

For example, you would add the value "stuff" into a table named "table" in a database named "database" into a field named "field".

This is how you would do it:
$db = "database"; // the name of the database
$insert = "INSERT INTO table (field) VALUES 'stuff'";
$add = mysql($db,$insert);
if (!$add) {
print "failed to add data.\n";
} else {
print "data added successfully.\n";
}

[/tt]

I think that should do it.

Hope this helps,

-Vic vic cherubini
malice365@hotmail.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
Thanks guys i think your tips are very helpful for me

Qwark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top