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!

trying to connect to mysql with php

Status
Not open for further replies.

davaddavad

Programmer
Jan 15, 2002
7
US
How do i add the show table command to this script? 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();
?>

 
$query=&quot;SHOW TABLE&quot;;
I added this line although i didnt get an error it didnt show any tables either
 
Thanks for your time. Well now i have an understanding of the 4 steps I will try to get the fetch and the output to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top