/    Sign up×
Community /Pin to ProfileBookmark

MySQL test page wouldn’t work

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* hoping it’s a mistake with my PHP because I haven’t used it so long, and not a problem with MySQL again. Here’s the code I used:

[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>”;

[/code]

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);
[/code]

If anyone has any suggestions as to what is wrong, I’m all ears ?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@agent_x91authorAug 11.2007 — Never mind, I just tried using the same queries using the MySQL Administrator logged into the same user account, and realised that the account I was using has virtually *no* permissions at all ?.

Thanks anyway ?
×

Success!

Help @agent_x91 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...