Jul 26, 2008

Where Am I Going Wrong This Time? - Can't enter data into database

Free Web Hosting, No Ads > CONTRIBUTE > The Internet > Web Design

free web hosting

Where Am I Going Wrong This Time? - Can't enter data into database

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

 

 

 


Reply

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

Reply

mrdee
Since I have been having trouble constantly, I installed everything according to this site:
Installing Apache 2.0 and PHP 5 (And MySQL)

Reply

mrdee
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). laugh.gif

Reply

jlhaslip
Great package.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : wrong, time, enter, data, database

  1. Need Help With My Database [resolved]
    retrive data as a link (6)
  2. Index In A Mysql Database
    Make the numbers follow (3)
    I hope I am on topic here (It does have to do with web design, after all). I have noticed that in a
    MySQL database, the 'id' field just keeps its numbers for every record, with the backdraw
    that, whenever you remove (a) record(s) from the table, you get your list numbered as eg.
    1,5,6,7,12,25 etc. This makes it a bit difficult of keeping track of the number of records in your
    table. Is there a way of achieving (either in PHPMyAdmin or through the use of PHP) that the id
    field in your table gets sort of 'refreshed and updated' so you have a clearer view....
  3. Treating .csv Files As Database Data
    Showing .CSV data on a web page (2)
    I use a nice program (which I helped to beta test) called ' Simfatic Forms ' to generate
    forms on web pages. The only problem is that it does not (yet) support MySQL databases, it saves the
    form data as a .CSV file. Now I was wondering if you can do the same with a .CSV file as you do
    with a MySQL databse, ie. displaying the data in that file on a web page which adjusts automatically
    as data are added to the file. To clarify: eg. if I make a form to sign a petition online, the data
    are saved to a .CSV file every time someone fills in the form, is it now possibl....
  4. Accessing Mysql From Javascript
    Javascript to communicate with database (4)
    I found a nice program which allows you to put quizzes on your web site. You can design your own
    questions, set the layout of your page, and there is also a possibility of having the results
    emailed to you. It further offers a facility to store the results and all that, all you have to do
    is put a link in the program, telling it which page takes care of that. However, when I look at the
    HTML code the program generates, I see that most of it is written in Javascript. Obviously, it also
    uses variable names, but as I don't know any Java, I was wondering if those variab....
  5. Another Question On Mysql Table Data Type
    text field for lots of text. (1)
    In my MySQL table I would like to use one text field which can contain lots of text. What I want to
    use it for is for student records, and I want to be able to add to it without destroying what is
    already there. I want the field to contain something like: ****03/11/2007**** Chopin prelude No 9:
    small problem bars 12-15. Advice given on how to practice. ****10/11/2007**** Problem in Prelude
    overcome, piece successfully completed. New piece set: Beethoven Sonata No 1, movement 1. etc. This
    is of course just an example, but that is how I want to set up my student records....
  6. Which Data Type To Use In Mysql Table
    Using a 5 character number (4)
    If I wanted to use an ID field which automatically increments when data are addad, but displays the
    ID as a 5 figure number, which data type would I have to use? I would want a type that assigns a
    number to a record in the format "00001", "00002", etc. However, when I use "int" as datatype, it
    only displays th field contents as "1", "2" etc. So, which data type could do the job for me? i do
    not need a decimal point or anything, just an id that displays in 5 figures, including the leading
    zeros. Thanks in advance.....
  7. Help With Database
    (24)
    I know I might sound a bit novice, but I'd like to know how to make a register and login
    database. I'm making a serious website for the very first time and I can't find on internet
    how to make one (don't even know how it is named). I would really appreciate me if someone could
    link me to a tutorial or give me the explanation, also the program to use (I think Microsoft Access
    is good?)....
  8. Merging Database Php Mysql
    (5)
    Hii i need help margning script. i have coppermine gallery, AzDGDating Site, Noah's
    Classifieds they all have user sign-up login. but they have different like i need to have 3 seperate
    account for each script is there any way like mergning one user name and password would work for 3
    section. if you don't get my question please tell me i will try to explain more in detail
    thank you for your time and help ....
  9. Help Or Advise Needed For Access Database Webpage Conversions
    I need some help with getting a linked webform so that the data can be (0)
    Hello All. I'm looking for some advise or assistance with getting a web page/access page
    running so that i can have the page online and collect the data live into my database for Project
    Management... Currently I'm developing a database using M$ Access, and need to have staff
    data enter sales information directly into a web form that can be linked to a database? I've
    looked at using a M$ Front page web form with data collected into a .CSV text file and
    extracting the data but i need to be able to let the staff review and update the data for eac....
  10. How Do You Combine Multiple Mysql Databases Into One Database?
    (3)
    How do you combine multiple mysql databases into one database? I was thinking thta soem servers
    restrict you to one to five mysql databases. If I have a dynamic part of a table on my site, I
    would use one database for that. For every table of dynamic information, I use one database. Can I
    streamline what I am doing and combine all of my databases into one? I could make multipple tables
    in the same database. Would that work? thanks....
  11. Import From Excel File Into Mysql Database
    (7)
    Has anyone tried using the excel import function that comes with phpmyadmin
    http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
    is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
    to import the data to , there is a link on the bottom left corner which says "insert data from a
    text file into the table" - although it says text file it still can be used to import an excel file.
    When you click on this link you will be taken to a page where you will be asked for the file name
    (the....
  12. Free Dhtml Menu That Reads A Database
    Anyone know one? (7)
    Hey, anybody know a DHTML menu that reads info from a database? for people who don't know, just
    like windows' "start menu" with the popup menus I want to mod it so that in phpnuke I can edit
    it admin panel end. I would like it to be vertical. Do not use note tags because they are only for
    admins and moderators. ....

    1. Looking for wrong, time, enter, data, database

Searching Video's for wrong, time, enter, data, database
advertisement



Where Am I Going Wrong This Time? - Can't enter data into database



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE