Old 28-01-2008, 07:57   #1 (permalink)
Witchfinder
Registered User
 
Join Date: Jan 2008
Posts: 13
Update database with PHP

Alright,
I've got a problem with the php in relation to updating a mysql database. I've created a dropdown menu which is formed using the rows from the database to select a product to update. That part of the site works fine but when it loads the web page with the form to update that products details I get the following error including printing post:

Last edited by Witchfinder : 17-02-2008 at 10:21.
  Reply With Quote
Old 28-01-2008, 08:07   #2 (permalink)
Hunch
Grumpy old man
 
Hunch's Avatar
 
Join Date: Oct 2007
Location: North Japan
Posts: 1,672
A quick glance at the errors would suggest the following:

It's saying that $_POST['cycleID'] doesn't exist - you need to check the code on the previous page - it's probably because your <select> is called 'edit' for some reason and not 'cycleID'.

However, PHP is very forgiving, so this is just a notice, not a fatal error, and the code continues to execute. Presumably when it gets to the SELECT statement,

SELECT * FROM cycles WHERE cycleID = $cycleID <-missing

$cycleID has no value and so the SQL is invalid because one of the parameters is missing.

Bear in mind your code is horribly insecure at the moment - be absolutely sure you nail down the referrer, or use prepared statements and mysqli otherwise you're a sitting duck for SQL Injection attacks.
  Reply With Quote
Old 28-01-2008, 08:11   #3 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,931
<select name = "edit">

should be

<select name = "cycleID">

perhaps?
__________________
  Reply With Quote
Old 28-01-2008, 08:15   #4 (permalink)
Hunch
Grumpy old man
 
Hunch's Avatar
 
Join Date: Oct 2007
Location: North Japan
Posts: 1,672
Too slooooow
  Reply With Quote
Old 28-01-2008, 08:29   #5 (permalink)
Witchfinder
Registered User
 
Join Date: Jan 2008
Posts: 13
Bingo, cheers for the speedy replies.
  Reply With Quote
Old 28-01-2008, 08:35   #6 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,931
Quote:
Originally Posted by Hunch
Too slooooow
All credit to you on that, I just concluded your lead.
__________________
  Reply With Quote
Old 28-01-2008, 08:45   #7 (permalink)
Hunch
Grumpy old man
 
Hunch's Avatar
 
Join Date: Oct 2007
Location: North Japan
Posts: 1,672
Hehe - just kidding. He probably read mine, then read yours and just did what you said.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8