Seite 1 von 1

SQL Update geht nicht!

Verfasst: 14.11.2006, 18:13
von bgx
Hi!

Warum beschreibt er mir die Configtabelle nicht, wenn ich folgendes Script starte?

Code: Alles auswählen

$style = array(
        'default'=>'',
        '14.11.'=>'snowSilver',
        '06.01.'=>'subSilver'
    );

$now = date('d.m.');
$img = isset($style[$now]) ? $style[$now] : $style['default'];

if ($img='snowSilver')
{
if ( !file_exists($phpbb_root_path . 'cache/snowSilver.' . $phpEx) )
{
			$sql = "UPDATE " . CONFIG_TABLE . " SET
				config_value = '2'
				WHERE config_name = 'default_style'";
  $file_style = fopen ( $phpbb_root_path . 'cache/snowSilver.'.$phpEx, 'w');
  fwrite ( $file_style, "AKTIV" );
  fclose ( $file_style );
unlink ($phpbb_root_path . 'cache/config_table.'.$phpEx);
}}
//echo 'test<img src="', $img, '" alt="', $img,'/>';
else if &#40;$img='subSilver'&#41;
&#123;
if &#40; file_exists&#40;$phpbb_root_path . 'cache/snowSilver.' . $phpEx&#41; &#41;
&#123;
			$sql = "UPDATE " . CONFIG_TABLE . " SET
				config_value = '1'
				WHERE config_name = 'default_style'";
unlink &#40;$phpbb_root_path . 'cache/config_table.'.$phpEx&#41;;
unlink &#40;$phpbb_root_path . 'cache/snowSilver.'.$phpEx&#41;;
&#125;&#125;
Wenn ich die gleiche SQL-Abfrage ausserhalb des if-Blocks setze, beschreibt er Sie.

ein echo innerhalb der if-Abfrage zeigt er korrekt an. :roll:

EDIT:

Diese Code ist sogar noch besser:

Code: Alles auswählen

$style = array&#40;
        'default'=>'',
        '14.11.'=>'snowSilver',
        '06.01.'=>'subSilver'
    &#41;;

$now = date&#40;'d.m.'&#41;;
$img = isset&#40;$style&#91;$now&#93;&#41; ? $style&#91;$now&#93; &#58; $style&#91;'default'&#93;;

if &#40;&#40;$img='snowSilver'&#41; AND &#40; $board_config&#91;'default_style'&#93; = '1' &#41;&#41;
&#123;
			$sql = "UPDATE " . CONFIG_TABLE . " SET
				config_value = '2'
				WHERE config_name = 'default_style'";
unlink &#40;$phpbb_root_path . 'cache/config_table.'.$phpEx&#41;;
&#125;
else if &#40;&#40;$img='subSilver'&#41; AND &#40; $board_config&#91;'default_style'&#93; = '2' &#41;&#41;
&#123;
			$sql = "UPDATE " . CONFIG_TABLE . " SET
				config_value = '1'
				WHERE config_name = 'default_style'";
unlink &#40;$phpbb_root_path . 'cache/config_table.'.$phpEx&#41;;
&#125;
Aber auch hier klappt es nicht mit dem SQL-Update der Config Tabelle

Verfasst:
von

Verfasst: 14.11.2006, 18:16
von Pompom
In deinem Code sehe ich nur, dass du eine SQL-Query zusammenbastelst, jedoch nicht, dass du sie auch in die Datenbank schreibst.

Verfasst: 14.11.2006, 18:44
von bgx
Boah!

Stimmt :o

Man sollte nicht solang am Rechner sitzen, dann klappt das auch. :D

Danke!

Hat geklappt

Verfasst: 14.11.2006, 18:59
von Pompom
jojo, hin und wieder mal Pause machen, sonst :crazyeyes: :crazyeyes: :crazyeyes: :crazyeyes: :crazyeyes: