Welcome! Log In Create A New Profile

Advanced

HELP INSERT PAGE

Posted by 47352361 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
HELP INSERT PAGE
March 13, 2012 12:22PM
Hi anyone please help me on my INSERT page, it cannot post the data i inserted into it to the database it displays error saying that i have UNDEFINED INDEX on my variables. please help!
Re: HELP INSERT PAGE
March 13, 2012 01:49PM
Send screenshot of your error...
avatar
Mac
Re: HELP INSERT PAGE
March 14, 2012 08:28AM
Read tut letter which says read previous forums.......
Re: HELP INSERT PAGE
March 14, 2012 12:28PM
And where do i find that tut?
avatar
Mac
Re: HELP INSERT PAGE
March 15, 2012 07:41AM
47352361 Wrote:
-------------------------------------------------------
> And where do i find that tut?

You must be joking.
Re: HELP INSERT PAGE
April 02, 2012 12:36PM
Please help. The code does not insert the data into the module table.

Language: PHP
<?php   / //insert into database     } } ?>

Edit: Do not post complete code
avatar
Mac
Re: HELP INSERT PAGE
April 03, 2012 07:11AM
USe error checking like this:

Language: PHP
$result = mysql_query(......); if (!$result) { die(';Invalid query: '; . mysql_error()); }
Re: HELP INSERT PAGE
May 07, 2012 04:45PM
Good day Mac,

I have checked all the forums, as well as Googled this problem to death. Home and learn also could not help me with a solution. Please assist.

I connect to database and server using a function. I am able to edit records, so the problem is not with the database connection.

When using the insert function I do not receive a connect error or any other error , but I do receive the successful message, however no records are added.

Here is my insert statement. Please let me know if I need to show more pieces of the code.

Language: PHP
if (isset($_REQUEST[';insert';])) { $dvd = $_REQUEST[';cddvd_title';]; $artist = $_REQUEST[';artist_name';]; $price = $_REQUEST[';price';];   $insert="INSERT INTO products (cddvd_title, artist_name, price) VALUES(';$dvd';, ';$artist';, ';$price';)" or die (mysql_error());
avatar
Mac
Re: HELP INSERT PAGE
May 07, 2012 05:18PM
Well, the"or die (mysql_error()" part will indicate if the error is with the insert query (that is the purpose of it). If it does not, then you need to look elsewhere. For example, inserting a simple echo statement used directly after the if statement is a simple test to figure out where the code stops.

Language: PHP
if (isset($_REQUEST[';insert';])) { echo "Yebo!"; } else{ echo "Check the $_REQUEST"; }

Use brackets to define you if/else statements.
Re: HELP INSERT PAGE
May 07, 2012 06:52PM
Thank you for the quick reply.

Sorry the if bracket is there, I just failed to copy and paste it.

The problem is that the code does not stop working. It runs al the way through to the echo statement that states the record was inserted successfully.

And as I said the connection to the database is solid, because I use the same function to connect for the Edit function and it works.
avatar
Mac
Re: HELP INSERT PAGE
May 08, 2012 06:36AM
Which implies some of your code is not correct? For example the sql statement in brackets

Language: PHP
$insert=("INSERT INTO products (cddvd_title, artist_name, price) VALUES(';$dvd';, ';$artist';, ';$price';)") or die (mysql_error());
Re: HELP INSERT PAGE
May 08, 2012 09:22AM
Thank you Mac,

I fixed the sql statement like you showed me, but not only does it still not insert a record, but now the database has lost the first 6 records.

I have been experiencing these type of problems right through the programming of the portfolio. I had to reload EASYphp and rebuild the database 3 times. All three times the database just suddenly refused to go into PHPMyAdmin and gave me a "phpMyAdmin error: 1045- Access denied for user 'root'@'localhost' (using password: NO)". I might be wrong but I am starting to think some of the problems I am experiencingare software related.

It is too late for me to start using Xampp, but I will load Firefox and see how it goes.

Thanx for your assistance
avatar
Mac
Re: HELP INSERT PAGE
May 08, 2012 11:41AM
Using Firefox is not going to solve the problem. There are many reasons why this could happen (e.g. you are inserting text containing a quote - need to use mysql_real_escape_string function) , and I cannot possibly list them all. If an error is not generated by "or die (mysql_error()); " then it means the query is fine, and you need to look at the db itself. Are all the fields correctly defined, what is sent to the db etc.
Re: HELP INSERT PAGE
May 08, 2012 02:40PM
Thanx,

I will double check and triple check everything. Is it possible that my database may be corrupted? I am still losing records without deleting and where my list used to display perfectly it is nowdisplaying messed up, without any code having been changed. (I'm aware of all the possible reasons that could cause errors to appear, I am just asking about the database because it is completely unknown to me, this is the first time for me with mySql).
Sorry, you do not have permission to post/reply in this forum.