Jump to content

Setting up databases


musicman07

Recommended Posts

I am new to Heliohost as I am learning PHP and MYSQL. I con't quite see how to set up a database using MYSQL. I entered the following code which worked in WAMP Server but not my Heliohost site (html code was an afterthought).

 

<html>

<body bgcolor = "#0000f>"

<font color = #fffff">

 

<?php

require("connect.php");

 

mysql_query("CREATE TABLE `phpacademy`.`people` (

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`firstname` VARCHAR( 25 ) NOT NULL ,

`lastname` VARCHAR( 30 ) NOT NULL ,

`dob` DATE NOT NULL ,

`gender` VARCHAR( 1 ) NOT NULL

)");

 

mysql_query("INSERT INTO `phpacademy`.`people` (`id`, `firstname`, `lastname`, `dob`, `gender`) VALUES (NULL, 'John', 'Headen', '1989-07-12', 'M'), (NULL, 'Emily', 'Headen', '1988-09-12', 'F')");

 

 

$extract = mysql_query("SELECT * FROM people ORDER BY id ASC");

$numrows = mysql_num_rows($extract);

 

echo "<br>";

 

while ($row = mysql_fetch_assoc($extract))

{

$id = $row['id'];

$firstname = $row['firstname'];

$lastname = $row['lastname'];

$dob = $row['dob'];

$gender = $row['gender'];

 

echo ("<br>$firstname $lastname was born in $dob");

 

}

 

 

?>

 

<br><br>What we see here is a basic example of editing a PHP site using Mysql to retrieve info from the database.

 

</body>

</html>

 

It is not working on Heliohost though. The Connect part works and the echo statements are working fine, but clearly the data is not being saved and retrieved. I am puting everything in public_html and uploading with CoffeeCup Direct FTP.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...