This is what I was getting at.
The following is correct mysql syntax in which a comma must be added after
each field - except for the last field - in this case price:
i.e.,
.................
CREATE TABLE chairs(
id int(5),
item varchar(50),
desc text,
price float
);
.........................
However, within the loop in her script it says to add the comma after _each_
field since there is no way of knowing when the loop will end.
Thus, why is she directing the script - after the loop has ended - to lop
off the last comma by using the
substr() function call as in:
if ($field_length[$i] != "")
{
$sql .= "($field_length[$i]) , ";
}
else
{
$sql .= ", ";
}
loop is finished.
and then...
$sql=substr($sql,0,-1); //which basically says to take the existing sql
statement string from the beginning to the next to last character and
return it to the variable $sql thus taking off the comma.
Am I on the right track?
Thank you.
Tony Ritter
.......................................
Ernest E Vogelsinger" <[EMAIL PROTECTED]
> No. The reason for the comma is that SQL dictates that column names in a
> create table statement are separated by a comma.
>
> This is valid SQL:
> create table chairs(
> id int(5),
> item varchar(50),
> desc text,
> price float
> );
>
> This is invalid and generates an SQL error when passed to the server:
> create table chairs(
> id int(5)
> item varchar(50)
> desc text
> price float
> );
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php