Jump to content

Recommended Posts

Posted

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.

Posted

Did you create a database and add a user to it? What are the names that you're using for the database and user? Do you give correct permissions when you added the user to the database?

Posted

Cheers Wizard. No I don't think I did any of that. Where does it tell you how to do this in Heliohost?

 

I assume the mysql_query commands are creating a database somewhere on the server. How to I assign user privileges?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...