Good idea.
I tried all sorts of combinations locally (XAMPP) and on my provider. Results below. The echo statements show me that the rest is functioning as it should.
There’s a $25 dollar reward to the one who solves the mystery.
Mike
The complete coding.
<?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;
?>
The results.
LOCAL & SERVER - BOTH PUT the word 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 value of $ct1[$ix]
SERVER - PUTS NOTHING IN ALL ROWS = no changes
$query = "UPDATE books SET catalog='$ct1[$ix]'";