Sagewire Logo

php5 mysql5.0 win problems

3 Message(s) by 2 Author(s) originally posted in php sql


From: miso Date:   Friday, September 14, 2007
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','$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


From: J.O. Aho Date:   Saturday, September 15, 2007
wrote in message:
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','$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'd 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'll get the error message.When you found the error and fix it, comment out those two lines.

--

//Aho


From: miso Date:   Sunday, September 16, 2007
Stupid me... I found the error (tourneyid, tourneygid - was empty and I have
to put some values for that)
Thans for sugestion :)

wrote in message:
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','$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'd 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'll get the error message.
When you found the error and fix it, comment out those two lines.
--


> //Aho



Next Message: Unique constraint for the columns doesn't work when one of values is null.



Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional