Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Connect To Sql (read Note), You Can Connect To MY Sql With PHP
farsiscript
post Apr 8 2006, 01:06 AM
Post #1


Super Member
*********

Group: Members
Posts: 357
Joined: 8-April 06
Member No.: 21,487



hi all
this is my first Tut
i hope you enjoy it
At first Open Notepad.exe
then write this code ::
CODE
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("news") or die(mysql_error());
?>

And Save it With Connect.php name
With that code you can connect to MySql to manage (add/Delete/Update) Row or .....
and now we talk about that code :
<?php <------------- at first line php is begin ------------- >

mysql_connect("localhost","username","password") or die(mysql_error());

localhost :: where is your sql ! if your sql in your CPanel You must write localhost
Username :: like username
password :: like sql password

mysql_select_db("databasename") or die(mysql_error());
Databasename = Your database name
* if Your domain is asd.com and then you make news database your database name = asd_news

?> <------------- end of php ------------- >
with this script you can just connect to database for read / write / delete / update you must user query

have good time

Notice from saint-michael:
do not accept this tutorial since this tutorial is more for larger php/mysql scripts that require this connection script to be used.
Go to the top of the page
 
+Quote Post
lefos
post Apr 22 2006, 10:40 PM
Post #2


Newbie
*

Group: Members
Posts: 2
Joined: 22-April 06
Member No.: 22,297



I use this as a script for noobs, it works easy


CODE
mysql.php

$server = "localhost"; //Deafault is localhost, only change if you are using this script remotely
$user = "root"; //mysql user
$password = ""; /mysql pass
$database="db"; //databse

#############################
####DO NOT EDIT BELOW THIS LINE####
############################
mysql_connect($server, $user, $pass) or die("Could not connect to mysql: ".mysql_error());
mysql_select_db($database) or die("Could not connect to mysql database: ".mysql_error());


then in any page you want to use, as long as it is in the same folder, do
CODE

<?php include("mysql.php"); ?>
<html> <body>page here</body</html>
Go to the top of the page
 
+Quote Post
farsiscript
post Apr 25 2006, 12:55 PM
Post #3


Super Member
*********

Group: Members
Posts: 357
Joined: 8-April 06
Member No.: 21,487



Yes In big CMS Connecting To Database In One File and an other File include Database File
its mean don't write 20 line code for every page .
In Big CMS this File name is config.php some times setup.php or db.php
but config.php is popular
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Im Making A Mmorpg >>(14)
  2. Trap17 Gets Supernatural: Topics Disappear!(7)
  3. Read This At Any Cost Before Posting Here(8)
  4. Connect To Remote Oracle Database With Toad(7)
  5. Cannot Connect With Ftp [resolved](3)
  6. Eragon(53)
  7. Read-only Folders In Xp(13)
  8. Last Book You Read?(192)
  9. Add Another Bad Note To The Olympics(12)
  10. A Problem With Ftp Clients(9)
  11. Living Everyday Happily And Meaningfully(5)
  12. Dvd Drive Problem(10)
  13. Compatibility/major Question(5)
  14. Two Lan Ports Problem(3)
  15. Read This Before Applying For Hosting!(56)
  1. How To Disable Flashing In Windows Freecell(0)
  2. Me And My Dogs(2)
  3. Who Is The Best Writer Did You Ever Read And His Or Her Book(10)
  4. Could Not Connect To 2wire, Wireless(6)
  5. Beside novel or friction, what do you read?(5)
  6. Can't Read E-mail(0)
  7. Read File (.txt) On Another Website Using Jsp?(3)
  8. Free Web Hosting Application [screened] [approved](6)
  9. **** Read Before You Post! ****(47)
  10. Free Wap! Omg!(4)
  11. Can You Read In Your Dreams?(24)
  12. Hackers Hijack A Half-million Sites: Phpbb Forum Users Must Read(8)
  13. Cpanel Raw Acess Log(1)
  14. Ftp Access Has Stopped Working All Of A Sudden [resolved](5)
  15. Have You Read The Rules?(27)


 



- Lo-Fi Version Time is now: 6th September 2008 - 02:00 AM