Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 09-01-05
Frostie's Avatar
Moderator
 
Join Date: Aug 2003
Location: Wirral
Posts: 3,012
Thanks: 7
Thanked 13 Times in 6 Posts
Frostie is on a distinguished roadFrostie is on a distinguished road
  mySQL Insert stopped working?

Not sure whats happened, yesterday everything was working sweet, ready to go live on Monday - and now when I complete a form, I am getting the following;
Warning: extract(): First argument should be an array

The form just pastes some info into a table using;
INSERT INTO table (field1, field2) VALUES ('$value1', '$value1')

Any ideas as to why its stopped working
__________________
Affiliate Blog | Eco Friendly | Discount Codes - Exclusive codes = Inclusion in newsletter to 26,000 recipients
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-01-05
Frostie's Avatar
Moderator
 
Join Date: Aug 2003
Location: Wirral
Posts: 3,012
Thanks: 7
Thanked 13 Times in 6 Posts
Frostie is on a distinguished roadFrostie is on a distinguished road
  Found the lines causing problem

The lines that are causing the problem are;

PHP Code:
<?
/* COMMENT: Extracts informatiom from the products table, based on the
productID variable passed from pervious pages */
$productID=$_GET[productID];
$queryExtract ="select * from products where id='$productID'";
$resultExtract mysql_query($queryExtract)
    or die (
"Could not find details");
$rowExtract mysql_fetch_array($resultExtract);
extract ($rowExtract);
The reason why I have called them $resultExtract is simply because I have a number of $results, $query and $row - just makes it easier for me (supposedly) to follow.

When the page loads, it is extracting the info correctly from the query, but later on, when I try to INSERT certains bits into another table, it doesn't as the fields show as blank in the database
__________________
Affiliate Blog | Eco Friendly | Discount Codes - Exclusive codes = Inclusion in newsletter to 26,000 recipients
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-01-05
Registered User
 
Join Date: Mar 2004
Location: Reading, UK
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
dmorison is an unknown quantity at this point
Hi Chris,

If the warning that you posted in your first message:

Quote:
Warning: extract(): First argument should be an array
...is being generated by extract ($rowExtract); from your code excerpt; then the implication is that your query did not return any results.

This is because mysql_fetch_array() will return FALSE if there are no [more] results to fetch, so it looks like you are passing the value FALSE to the extract() function.

However, prior to that in your code; I notice that you are aborting with "Could not find details" only if mysql_query() returns an error. Note that your query returning zero rows is not an error condition, so you may be wrongfully assuming that your query has actually returned some data.

Instead of aborting on error; I would use mysql_num_rows after your query, something like:

PHP Code:
$queryExtract ="select * from products where id='$productID'";
$resultExtract mysql_query($queryExtract);
if (!
mysql_num_rows($resultExtract)) {
  echo(
"Could not find details");
  exit();

Hope this helps a little...!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-01-05
Frostie's Avatar
Moderator
 
Join Date: Aug 2003
Location: Wirral
Posts: 3,012
Thanks: 7
Thanked 13 Times in 6 Posts
Frostie is on a distinguished roadFrostie is on a distinguished road
  Hmmm

Now I am getting the message "Could not find details"

But, the details are being extracted because it makes up part of the page??????

My head is getting very sore now lol
__________________
Affiliate Blog | Eco Friendly | Discount Codes - Exclusive codes = Inclusion in newsletter to 26,000 recipients
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 10-01-05
Northern Monkey's Avatar
Member
 
Join Date: Jan 2004
Location: UK
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Northern Monkey is an unknown quantity at this point
Ello,

output the mysql_error() and let me know what you get, also what are the field types in your table and output the values that you are trying to insert into the table and let me know, then I'll have a go on my server.

P.S. Hows the charity for you missus getting on?

Also can you help on one of my postings in this forum??

Ta.

Chris.
__________________
Holiday Villa In<br>
<font size=2>If it moves, kick it. If it doesn't move, kick it till it moves and hen kick it because it moved</font>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-01-05
Frostie's Avatar
Moderator
 
Join Date: Aug 2003
Location: Wirral
Posts: 3,012
Thanks: 7
Thanked 13 Times in 6 Posts
Frostie is on a distinguished roadFrostie is on a distinguished road
  Sorted

Managed to get it sorted earlier this morning - it was a stupid error (should have known) but now all the variables are being passed and stored correctly.

Thanks all that helped me on this.

Monkey - Wifes fund raising is going well - still waiting for a couple of people who have the money, but not yet forwarded it on. Also have 1 VERY kind person who has offered to make up any difference too.

The site actually needs updating to reflect the new total

The training is... erm... well over Christmas, it kind of went backwards! lol
__________________
Affiliate Blog | Eco Friendly | Discount Codes - Exclusive codes = Inclusion in newsletter to 26,000 recipients

Last edited by Frostie; 10-01-05 at 05:53 PM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7