I’m a bit out of practice with MySQL and PHP, haven’t really used them for quite a while. I also set up my own server about a month or two ago, and have been developing a webpage. However, until recently MySQL was not working (and since I didn’t really need to use it at the moment, I didn’t bother configuring it properly). However, I managed to get it working today, and have used the administrator to create a database, and a table within that database called “personal_information”.
However, when attempting to retrieve some sample data from the table (which I gave two records which I made up in order to test MySQL), I kept getting an error when using the mysql_fetch_array function, stating that the resource was invalid. I also tried another query to add a value to the database and then checked it using the MySQL administrator, but found that the INSERT INTO query hadn’t worked either.
I’m *really
[code=php]
$connection=mysql_connect(“localhost”,”<omitted>”,”<omitted>”);
mysql_select_db(“<omitted>”,$connection);
$query=”SELECT * FROM personal_information”;
$result=mysql_query($query);
$row=mysql_fetch_array($result);
extract($row);
echo $row[‘forename’].” “.$row[‘surname’].”: “.$row[’email’].”<br><br>”;
And the second time, when attempting to add a new row:
[code=php]
$connection=mysql_connect(“localhost”,”<omitted>”,”<omitted>”);
mysql_select_db(“<omitted>”,$connection);
$query=”INSERT INTO personal_information(forename,surname,email) VALUES (‘John’,’Smith’,’[email protected]’)”;
$result=mysql_query($query);
If anyone has any suggestions as to what is wrong, I’m all ears ?