Hi,
My first topic. I'm going mad. The only part of this coding that doesn't work is the UPDATE statement. Can someone tell me why please? The echos prove the rest is functioning properly. After the code there are the results of the different attempts.
Fingers crossed,
Mike
<?php
include('misc.inc');
$connection = mysql_connect($host,$user,$password)
or die ('No connection');
$db = mysql_select_db($database,$connection)
or die ('No selection');
$query = "SELECT * FROM books";
$result = mysql_query($query)
or die('mysql error ' . mysql_error() . ' in query ' . $query);
$ct1 = array('Kunst','Kinderbüchen','Literatur','Geography','Photography');
$ix = -1;
while ($row = mysql_fetch_array($result))
{
extract($row);
$ix++;
$cat = $ct1[$ix];
echo $cat,"<br>",$ix,"<br>";
$query = "UPDATE books SET catalog='$cat'";
$result2 = mysql_query($query)
or die('mysql error ' . mysql_error() . ' in query ' . $query);
echo $catalog,"<br>",$ix,"<br>";
if ($ix == 4)
$ix = -1;
};
exit;
?>
LOCAL & SERVER - BOTH PUT cat IN ALL ROWS = it 'worked'!
$query = 'UPDATE books SET catalog="cat"';
$query = "UPDATE books SET catalog='cat'";
LOCAL & SERVER - PUTS '$cat' IN ALL ROWS = not the value of $cat
$query = 'UPDATE books SET catalog="$cat"';
LOCAL - PUTS NOTHING IN ALL ROWS = no changes
SERVER - PUTS the value of $ct1[3] IN ALL ROWS = not the value of $ct1[$ix]
$query = "UPDATE books SET catalog='$cat'";
LOCAL & SERVER - PUTS '$ct1[$ix]' IN ALL ROWS = not the value of $ct1[$ix]
$query = 'UPDATE books SET catalog="$ct1[$ix]"';
LOCAL - PUTS the value of $ct1[1] IN ALL ROWS = not the content of $ct1[$ix]
SERVER - PUTS NOTHING IN ALL ROWS = no changes
$query = "UPDATE books SET catalog='$ct1[$ix]'";