Im migrating from asp to php (not by choice exactly, I thought I was buying Domain hosting with asp, but infact the hosting uses php/mySQL - thanks maxipointservers.net!).I don't have a clue where to start. All the tutorials I can find want me to install mySQL etc. However I can't see why I need to do this since I am, effectively, renting server space with this already installed. So I want to CREATE TABLE in mySQL database but I dont have access to any sort of control panel that I can see so I upload a php script:
<?
$username = "*******";
$password = "*******";
$hostname = "localhost";
$database = "*******";
mysql_connect($hostname, $username, $password);
@mysql_select_db($database) or die("Could not select database"
;
$query="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))";
mysql_query($query);
mysql_close();
?>
I insert some test data from a form and try to select * from 'contacts' (the table above):
<?
$username="*******";
$password="*******";
$database="*******";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database"
;
$query="SELECT * FROM contacts";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"first"
;
$last=mysql_result($result,$i,"last"
;
$phone=mysql_result($result,$i,"phone"
;
$mobile=mysql_result($result,$i,"mobile"
;
$fax=mysql_result($result,$i,"fax"
;
$email=mysql_result($result,$i,"email"
;
$web=mysql_result($result,$i,"web"
;
echo "<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>";
++$i;
}
?>
And I get this error:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/virtual/site266/fst/var/ on line 12
Database Output
With asp I could use my 'Database Manager' to create my tables and it all seemed a lot clearer. Can anyone explain to me as if I'm a complete idiot, in words no more than two syllables, what my first steps should be in trying to create a table for mySQL? Thanks
<?
$username = "*******";
$password = "*******";
$hostname = "localhost";
$database = "*******";
mysql_connect($hostname, $username, $password);
@mysql_select_db($database) or die("Could not select database"

$query="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))";
mysql_query($query);
mysql_close();
?>
I insert some test data from a form and try to select * from 'contacts' (the table above):
<?
$username="*******";
$password="*******";
$database="*******";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database"

$query="SELECT * FROM contacts";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"first"

$last=mysql_result($result,$i,"last"

$phone=mysql_result($result,$i,"phone"

$mobile=mysql_result($result,$i,"mobile"

$fax=mysql_result($result,$i,"fax"

$email=mysql_result($result,$i,"email"

$web=mysql_result($result,$i,"web"

echo "<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>";
++$i;
}
?>
And I get this error:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/virtual/site266/fst/var/ on line 12
Database Output
With asp I could use my 'Database Manager' to create my tables and it all seemed a lot clearer. Can anyone explain to me as if I'm a complete idiot, in words no more than two syllables, what my first steps should be in trying to create a table for mySQL? Thanks