Home > Archive > PHP SQL > September 2007 > php5 mysql5.0 win problems
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
php5 mysql5.0 win problems
|
|
|
| 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','$newlocat
ion','$team1_id',";
$sql .=
" '$team2_id','$team1_div','$team2_div','$
newteam1_score','$newteam2_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','$newteam2_score',";
$sql .= "'$newseason','','','','','','1')";
)
because i know that i have to avoid id row to get it work.
please help
Miso
| |
| J.O. Aho 2007-09-15, 4:02 am |
| 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','$newlocat
ion','$team1_id',";
> $sql .=
> " '$team2_id','$team1_div','$team2_div','$
newteam1_score','$newteam2_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','$newteam2_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."<br>\n";
//put your sql query code here
echo mysql_error()."<br>\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
| |
|
| 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" <user@example.net> wrote in message
news:5l1kguF62m4gU1@mid.individual.net...
> miso wrote:
>
> 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.
>
>
>
> 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."<br>\n";
> //put your sql query code here
>
> echo mysql_error()."<br>\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
|
|
|
|
|