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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connect to mysql thru php

Status
Not open for further replies.

davaddavad

Programmer
Jan 15, 2002
7
US
Looking for the show table command to fit into this connection format using php

I hope it is ok to show this script if not mod delete it please. I just got php installed by my host and mysql. I dont have phpmyadmin or a mysql window. The only way I can connect is thru php. My host gave me the first half of the php page below. I added the select and create table from another script i found. I believe it built the table but I havent found the correct script to show the table to me. any help appreciated Dave


<?
$host=&quot;**********&quot;;
$dbase=&quot;********&quot;;
$login=&quot;********&quot;;
$passwd=&quot;********&quot;;
$cnx = mysql_connect($host,$login,$passwd);
if (!$cnx) {
print &quot;Error Connecting to MySQL server\n<BR>&quot;;
exit(0);
}
else {
mysql_select_db($dbase) or die(&quot;Error changing Database&quot;);
print &quot;Connected to database!\n<BR>&quot;;
}
@mysql_select_db($dbase) or die( &quot;Unable to select database&quot;);
$query=&quot;CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))&quot;;
mysql_query($query);
$query=&quot;SELECT * FROM contacts&quot;;
$result=mysql_query($query);
mysql_close();
?>

 
This is the Microsoft SQL Server forum. You would be better off posting your query in the forum for MySQL. Use the search function at the top of TEK-TIPS, select Find a Forum and enter MySQL.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top