Ok ill try and explain the problem, im pretty new to PHP and SQL so it wouldnt suprise me if ive made a dumb mistake.
Running Apache HTTP Server 2.0 or sumtin
PHP 5. sumtin
MySQL 5. sumtin
Here is the senario.
To start there are no entries into my database.
I enter details in the form and post to addMember.php5.
These details are entered correctly (viewed from MYSQL5 console)
Then i go to queryDB.php5 (queries DB and displays all the usernames in the table). However it doesnt show any usernames (there should be one). So i click refresh and it shows the username.
Enter another username into the database.
Run queryDB again and it only shows the first user name, click refresh and it shows both now.
I have no idea why this is happening, its like i.e is storing the result queryDB got last time and is only showing that.
Haha here is some code.
addMember.php5
<?php
$db = new mysqli("localhost", "root", "cdcdcd", "userInfo");
if (mysqli_connect_errno()) {
die('Unable to connect to database.');
}
$uName = $_POST['uName'];
$pWord = $_POST['pWord'];
$email = $_POST['email'];
$compNo = $_GET['compNo'];
print(" ".$uName." ".$pWord." ".$email." ".$compNo."Heya");
$query = $db->query("INSERT INTO users (uName, pWord, email, compNo) VALUES ('$uName', '$pWord', '$email', '0')");
$db->close();
?>
queryDB.php5
<?php
$db = new mysqli("localhost", "root", "cdcdcd", "userInfo");
if (mysqli_connect_errno()) {
die('Unable to connect to database.');
}
// All queries and commands go here.
$query = $db->query("SELECT uName,pWord,email,compNo FROM `users`");
while ($data = $query->fetch_assoc()) {
echo '<p>'.$data['uName'].'</p>';
}
$db->close();
?>
Any help would be greatly appreciated!
Thanks in advance, Nick