php5 mysql5.0 win problems

php5 mysql5.0 win problems

am 14.09.2007 17:30:22 von stjepko

I have problem with my php/sql code because id (auto inc., primary) row.
(
$sql = "INSERT INTO ".$_CONF['tprefix']."schedule_scores VALUES ";
$sql .= "('NULL','$newdate','$newtime','$newlocation','$team1_id',";
$sql .=
"'$team2_id','$team1_div','$team2_div','$newteam1_score','$n ewteam2_score',";
$sql .= "'$newseason','','','','','','1')";

)

this is code and i done this

(
$sql = "INSERT INTO ".$_CONF['tprefix']."schedule_scores (date, time,
location,
team1, team2, team1_div, team2_div, team1_score, team2_score, season,
summary,
pic_name, pic_caption, tourneyid, tourneygid, standings) VALUES ";
$sql .= "('$newdate','$newtime','$newlocation','$team1_id',";
$sql .=
"'$team2_id','$team1_div','$team2_div','$newteam1_score','$n ewteam2_score',";
$sql .= "'$newseason','','','','','','1')";
)

because i know that i have to avoid id row to get it work.

please help
Miso

Re: php5 mysql5.0 win problems

am 15.09.2007 10:47:25 von Shion

miso wrote:
> I have problem with my php/sql code because id (auto inc., primary) row.
> (
> $sql = "INSERT INTO ".$_CONF['tprefix']."schedule_scores VALUES ";
> $sql .= "('NULL','$newdate','$newtime','$newlocation','$team1_id',";
> $sql .=
> "'$team2_id','$team1_div','$team2_div','$newteam1_score','$n ewteam2_score',";
> $sql .= "'$newseason','','','','','','1')";
>
> )

As you already figured out, this won't work, as all columns are assumed
to have an insert value, while an auto inc column won't be happy about
getting a value.


> this is code and i done this
>
> (
> $sql = "INSERT INTO ".$_CONF['tprefix']."schedule_scores (date, time,
> location,
> team1, team2, team1_div, team2_div, team1_score, team2_score, season,
> summary,
> pic_name, pic_caption, tourneyid, tourneygid, standings) VALUES ";
> $sql .= "('$newdate','$newtime','$newlocation','$team1_id',";
> $sql .=
> "'$team2_id','$team1_div','$team2_div','$newteam1_score','$n ewteam2_score',";
> $sql .= "'$newseason','','','','','','1')";
> )
>
> because i know that i have to avoid id row to get it work.

Are you sure you get all the data into the $sql? I would suggest you add
the following to your code (while you debug)

echo $sql."
\n";
//put your sql query code here

echo mysql_error()."
\n";


This way you see the SQL statement and can see what is missing it and
you will get the error message.


When you found the error and fix it, comment out those two lines.

--

//Aho

Re: php5 mysql5.0 win problems

am 16.09.2007 16:38:29 von stjepko

Stupid me... i found the error (tourneyid, tourneygid - was empty and i have
to put some values for that)
Thans for sugestion :)

miro


"J.O. Aho" wrote in message
news:5l1kguF62m4gU1@mid.individual.net...
> miso wrote:
>> I have problem with my php/sql code because id (auto inc., primary) row.
>> (
>> $sql = "INSERT INTO ".$_CONF['tprefix']."schedule_scores VALUES ";
>> $sql .= "('NULL','$newdate','$newtime','$newlocation','$team1_id',";
>> $sql .=
>> "'$team2_id','$team1_div','$team2_div','$newteam1_score','$n ewteam2_score',";
>> $sql .= "'$newseason','','','','','','1')";
>>
>> )
>
> As you already figured out, this won't work, as all columns are assumed
> to have an insert value, while an auto inc column won't be happy about
> getting a value.
>
>
>> this is code and i done this
>>
>> (
>> $sql = "INSERT INTO ".$_CONF['tprefix']."schedule_scores (date,
>> time,
>> location,
>> team1, team2, team1_div, team2_div, team1_score, team2_score, season,
>> summary,
>> pic_name, pic_caption, tourneyid, tourneygid, standings) VALUES ";
>> $sql .= "('$newdate','$newtime','$newlocation','$team1_id',";
>> $sql .=
>> "'$team2_id','$team1_div','$team2_div','$newteam1_score','$n ewteam2_score',";
>> $sql .= "'$newseason','','','','','','1')";
>> )
>>
>> because i know that i have to avoid id row to get it work.
>
> Are you sure you get all the data into the $sql? I would suggest you add
> the following to your code (while you debug)
>
> echo $sql."
\n";
> //put your sql query code here
>
> echo mysql_error()."
\n";
>
>
> This way you see the SQL statement and can see what is missing it and
> you will get the error message.
>
>
> When you found the error and fix it, comment out those two lines.
>
> --
>
> //Aho