|
|
|
|
![]() ![]() |
Oct 27 2007, 01:55 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 273 Joined: 18-July 07 From: Slough (UK) Member No.: 46,682 |
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: QUOTE $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: CODE $query = "INSERT INTO members VALUES ('','John','Barnes','01234 567890','00112 334455','01234 567891','johnbarnes@gowansnet.com','http://www.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). |
|
|
|
Oct 27 2007, 02:17 AM
Post
#2
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,993 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
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. |
|
|
|
Oct 27 2007, 03:32 AM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 273 Joined: 18-July 07 From: Slough (UK) Member No.: 46,682 |
Since I have been having trouble constantly, I installed everything according to this site:
Installing Apache 2.0 and PHP 5 (And MySQL) |
|
|
|
Oct 28 2007, 02:42 AM
Post
#4
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 273 Joined: 18-July 07 From: Slough (UK) Member No.: 46,682 |
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). |
|
|
|
Oct 28 2007, 03:00 AM
Post
#5
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,993 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
Great package.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th September 2008 - 09:57 PM |