Jump to content


UPDATE Problem

  • Please log in to reply
3 replies to this topic

#1 Jan

  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 01 September 2003 - 10:42 PM

I cant figure out what i am doing wrong on this part in my php script.
mysql_connect($db_host, $db_name, $db_password) OR DIE (\"Konnte nicht mit MySQL verbinden.\");
@mysql_select_db($db_name) OR DIE (\"Konnte nicht mit Datenbank auf MySQL verbinden.\");
$res = mysql_query (\"SELECT * FROM taskoverview\");
$numberRows = mysql_num_rows($res);
for ($i = 0; $i < $numberRows; $i++)
$d_name = $_POST[\"name$i\"];
$d_beschreibung = $_POST[\"beschreib$i\"];
$d_duedate = $_POST[\"duedate_value$i\"];
$d_aufwand = $_POST[\"aufwand_table$i\"];
$d_status = $_POST[\"status_table$i\"];
$d_verantwortlich = $_POST[\"verantwort$i\"];
mysql_query (\"UPDATE taskoverview SET name=$d_name, beschreibung=$d_beschreibung, duedate=$d_duedate, aufwand=$d_aufwand, status=$d_status, verantwortlich=$d_verantwortlich)\");

$db_host, $db_name, $db_password are definetely set correctly.
the name of the table \"taskoverview\" exists and is spelled correctly.
and all the $_post variables are there. I checked them with some echo messages.
I get no error which makes me post it here.
Once again, id be greatful for help!!!
Thank you!

#2 Woodie

  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 01 September 2003 - 11:39 PM

This may sound a lttle basic but I do like to assign variables to all my MySQL statements - if purely for error checking!

But the only thing I woulkd alter in the update query is to place each variable into single quotes \'$foo\'......

mysql_query (\"UPDATE taskoverview SET name = \'$d_name\', beschreibung = \'$d_beschreibung\', duedate = \'$d_duedate\', aufwand = \'$d_aufwand\' , status = \'$d_status\', verantwortlich = \'$d_verantwortlich\')\");

#3 Dissonance

  • Members
  • PipPip
  • Member
  • 12 posts
  • LocationChicago, IL

Posted 01 September 2003 - 11:43 PM

There\'s an extra parenthesis at the end of your update query. And ditto about the single quotes. 8)
Friends don't let friends vote Republican.

#4 Jan

  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 02 September 2003 - 09:12 AM

thanks a lot!
everything works fine and it once again feels so good to finish somethin \"hand-made\" :wink:
keep helping guys you\'re great :!:

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users