Jump to content
xisto Community
mrdee

Where Am I Going Wrong This Time? Cant enter data into database

Recommended Posts

Hi,
on my local machine (with Apache 2.0, PHP 5.2.4 and MySQL 5.0) I come across weird things.
I have successfully made a table, but when I try to enter data into it it just will not accept the empty string for the first field (id).
This was the creation line:

$query="CREATE TABLE members (id int(20) auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";

This has created the table no problem.However, when I try to enter something into that table with the following command:

$query = "INSERT INTO members VALUES ('','John','Barnes','01234 567890','00112 334455','01234 567891','johnbarnes@gowansnet.com','http://gowansnet.com;;mysql_query($query);if (@mysql_query ($query)) {print '<p>The data entry was sucessful.</p>';} else {print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>.The query was $query.</p>";}mysql_close();

(and provision to see whether or not it succeeded), I get the following error:

Invalid value in id.
Then, when I try again, it does put data in, but in the wrong table, it either works or doesn't when I have to keep switching the opening tag from <? to <?php and back, ie. it says it has worked with the </ tag, but has not entered any data, then with the <?php tag, it tells me "Access denied", although correct username and password are in the script..
In other words, it seems like the whole system is running quite unstable.
I know I am not being very specific at times, but there is so much going on that i don't know what fault to post anymore.

Would it help if I posted a result from phpinfo()?

Thanks,
(Before I go completely nuts).

Share this post


Link to post
Share on other sites

I just added the Table to a DB and your query ran fine here on the Trap. Then I added an entry using your INSERT and it went in just fine. Repeating the INSERT added the second entry with a different ID number, of course.How did you configure your php and mysql? seperately? or using an installer like XAMPP? or WAMP?Maybe you should un-install the php and mysql then use one of the one-click installers??? might solve this one for you.Don't forget to copy/backup your htdocs folder first.

Share this post


Link to post
Share on other sites

I have simply thrown it all out. (Apache, PHP and MySQL).I came across a wonderful (and free) program today called EasyPHP, which gives you all this too, is less than 8 Mb in size, and at least it works, which means that I will be able to learn PHP/MySQL in peace now, without always having to upload my files for testing them.(And without my hair getting gray, or me having one heart attack after another). :rolleyes:

Share this post


Link to post
Share on other sites

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...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.