/    Sign up×
Community /Pin to ProfileBookmark

Trouble with mysql_fetch_array()

What does this mean and how will I go about fixing this? As I can’t see anything wrong with the line it is specifying.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in H:xampphtdocswwwtodo1uwafcstatsinstall.php on line 694

[code=php]
if ($row3 = mysql_fetch_array($result3)){
[/code]

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 15.2006 — It means your query failed (the mysql_query() line), and therefore $result3 "is not a valid MySQL result resource." [i]Always[/i] test the result of a query to make sure it worked before proceding with processing it, at least something like:
[code=php]
$query = "SELECT something FROM some_table WHERE some_column = 'something'"
$result = mysql_query($query) or die("SQL error: $query -- " . mysql_error());
[/code]
Copy linkTweet thisAlerts:
@solidaritiauthorJan 17.2006 — I'm not sure I understand, is it because I'm using query3, result3 somewhere else?

[code=php]
$query = "CREATE TABLE ".$DBprefix."playerpositions (
PlayerPositionID tinyint(1) unsigned NOT NULL default '0',
PlayerPositionName varchar(64) NOT NULL default '',
PRIMARY KEY (PlayerPositionID)
) TYPE=MyISAM;";

$result3 = mysql_query($query);
// check it it was succesfull
if ($result == 1)
{
$resultReturner .= "<tr><th>Creation of playerpositions table</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Creation of playerpositions table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";
}
// check if there isn't any data in the table.
$query3 = "Select * from ".$DBprefix."playerpositions where PlayerPositionsID='1'";
$result3 = mysql_query($query3);
if ($row3 = mysql_fetch_array($result3)){
$resultReturner .= "<tr><th>Creation of playerpositions table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Admin account already exists</td></tr>";
}else{
// create the matchplace home and away
$query2 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('1', 'GoalKeeper')";
$result2 = mysql_query($query2);
// check it it was succesfull
if ($result2 == 1){
$resultReturner .= "<tr><th>Insertion of 1 GoalKeeper</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 1 GoalKeeper</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query4 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('2', 'Defender')";
$result4 = mysql_query($query4);
// check it it was succesfull
if ($result4 == 1){
$resultReturner .= "<tr><th>Insertion of 2 Defender</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 2 Defender</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query5 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('3', 'Midfielder')";
$result5 = mysql_query($query5);
// check it it was succesfull
if ($result5 == 1){
$resultReturner .= "<tr><th>Insertion of 1 Midfielder</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 1 Midfielder</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query6 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('4', 'Forward')";
$result6 = mysql_query($query6);
// check it it was succesfull
if ($result6 == 1){
$resultReturner .= "<tr><th>Insertion of 4 Forward</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 4 Forward</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query7 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('5', 'Committee')";
$result7 = mysql_query($query7);
// check it it was succesfull
if ($result7 == 1){
$resultReturner .= "<tr><th>Insertion of 5 Committee</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 5 Committee</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query8 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('6', 'Manager')";
$result8 = mysql_query($query8);
// check it it was succesfull
if ($result8 == 1){
$resultReturner .= "<tr><th>Insertion of 6 Manager</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 6 Manager</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query9 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('7', 'Supporter')";
$result9 = mysql_query($query9);
// check it it was succesfull
if ($result9 == 1){
$resultReturner .= "<tr><th>Insertion of 7 Supporter</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 7 Supporter</th><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query10 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('8', 'Old Boy')";
$result10 = mysql_query($query10);
// check it it was succesfull
if ($result10 == 1){
$resultReturner .= "<tr><th>Insertion of 8 Old Boy</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 8 Old Boy</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}
}
[/code]
Copy linkTweet thisAlerts:
@NogDogJan 17.2006 — It's because the query failed, probably due to a syntax error. If you make the debugging change I recommended above, then you can get MySQL (via PHP) to give us more information to help figure out what the problem is.

Also, this looks suspicious:
[code=php]
$query = "CREATE TABLE ".$DBprefix."playerpositions (
PlayerPositionID tinyint(1) unsigned NOT NULL default '0',
PlayerPositionName varchar(64) NOT NULL default '',
PRIMARY KEY (PlayerPositionID)
) TYPE=MyISAM;";

$result3 = mysql_query($query);
// check it it was succesfull
if ($result == 1)
{
[/code]

You use $result3 to capture the return value from the mysql_query(), but then the following if() is checking the value of $result. Also, I doubt it returns 1 every time it succeeds, as the return value is a PHP-generated result link ID. I would try changing it to:
[code=php]
$query = "CREATE TABLE ".$DBprefix."playerpositions (
PlayerPositionID tinyint(1) unsigned NOT NULL default '0',
PlayerPositionName varchar(64) NOT NULL default '',
PRIMARY KEY (PlayerPositionID)
) TYPE=MyISAM;";

$result = mysql_query($query);
// check it it was succesfull
if ($result)
{
[/code]
Copy linkTweet thisAlerts:
@bokehJan 17.2006 — [code=php]$result3 = mysql_query($query);
// check it it was succesfull
if ($result == 1)[/code]
[/QUOTE]
Well that's not a proper check because [I]$result3[/I] is just the resource. Then in the if condition you are using a different variable name. Use [I]or die[/I] as demonstrated by Nogdog and then to check if a result was returned use [I]mysql_num_rows()[/I][code=php]$query = "SELECT something FROM some_table WHERE some_column = 'something'"
$result = mysql_query($query) or die("SQL error: $query -- " . mysql_error());
if(mysql_num_rows($result) > 0){
// data found
}else{
// data not found
}[/code]
Copy linkTweet thisAlerts:
@solidaritiauthorJan 17.2006 — I tried that, but these errors came up:


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in H:xampphtdocswwwtodo1uwafcstatsinstall.php on line 694

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in H:xampphtdocswwwtodo1uwafcstatsinstall.php on line 906

I've marked the lines in the below code, just to clear something up I can't use the same variable names can I have to change them. Thats what the above errors are moaning at aren't they?

[code=php]
$query3 = "CREATE TABLE ".$DBprefix."playerpositions (
PlayerPositionID tinyint(1) unsigned NOT NULL default '0',
PlayerPositionName varchar(64) NOT NULL default '',
PRIMARY KEY (PlayerPositionID)
) TYPE=MyISAM;";

$result3 = mysql_query($query3);
// check it it was succesfull
if ($result3)
{
$resultReturner .= "<tr><th>Creation of playerpositions table</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Creation of playerpositions table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";
}
// check if there isn't any data in the table.
$query11 = "Select * from ".$DBprefix."playerpositions where PlayerPositionsID='1'";
$result11 = mysql_query($query11);
if ($row11 = mysql_fetch_array($result11)){ //694
$resultReturner .= "<tr><th>Creation of playerpositions table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Admin account already exists</td></tr>";
}else{
// create the matchplace home and away
$query2 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('1', 'GoalKeeper')";
$result2 = mysql_query($query2);
// check it it was succesfull
if ($result2 == 1){
$resultReturner .= "<tr><th>Insertion of 1 GoalKeeper</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 1 GoalKeeper</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query4 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('2', 'Defender')";
$result4 = mysql_query($query4);
// check it it was succesfull
if ($result4 == 1){
$resultReturner .= "<tr><th>Insertion of 2 Defender</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 2 Defender</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query5 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('3', 'Midfielder')";
$result5 = mysql_query($query5);
// check it it was succesfull
if ($result5 == 1){
$resultReturner .= "<tr><th>Insertion of 1 Midfielder</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 1 Midfielder</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query6 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('4', 'Forward')";
$result6 = mysql_query($query6);
// check it it was succesfull
if ($result6 == 1){
$resultReturner .= "<tr><th>Insertion of 4 Forward</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 4 Forward</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query7 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('5', 'Committee')";
$result7 = mysql_query($query7);
// check it it was succesfull
if ($result7 == 1){
$resultReturner .= "<tr><th>Insertion of 5 Committee</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 5 Committee</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query8 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('6', 'Manager')";
$result8 = mysql_query($query8);
// check it it was succesfull
if ($result8 == 1){
$resultReturner .= "<tr><th>Insertion of 6 Manager</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 6 Manager</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query9 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('7', 'Supporter')";
$result9 = mysql_query($query9);
// check it it was succesfull
if ($result9 == 1){
$resultReturner .= "<tr><th>Insertion of 7 Supporter</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 7 Supporter</th><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}

// create the matchplace home and away
$query10 = "INSERT INTO ".$DBprefix."playerpositions (PlayerPositionID , PlayerPositionName) VALUES ('8', 'Old Boy')";
$result10 = mysql_query($query10);
// check it it was succesfull
if ($result10 == 1){
$resultReturner .= "<tr><th>Insertion of 8 Old Boy</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of 8 Old Boy</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}
}

[/code]
Copy linkTweet thisAlerts:
@solidaritiauthorJan 17.2006 — Heres the secnd error:

[code=php]
//
//Pelaajat taulu
//
$query = "CREATE TABLE ".$DBprefix."players (
PlayerID int(10) unsigned NOT NULL auto_increment,
PlayerFirstName varchar(32) NOT NULL default '',
PlayerLastName varchar(64) NOT NULL default '',
PlayerSeasonID int(11) unsigned NOT NULL default '0',
PlayerPositionID tinyint(1) unsigned NOT NULL default '0',
PlayerNumber tinyint(3) unsigned NOT NULL default '0',
PlayerDescription text NOT NULL,
PlayerProfile text NOT NULL,
PlayerPublish tinyint(1) unsigned NOT NULL default '1',
PlayerShowStats tinyint(1) NOT NULL default '1',
PlayerAllData tinyint(1) NOT NULL default '1',
PlayerTask varchar(128) NOT NULL default '',
PRIMARY KEY (PlayerID)
) TYPE=MyISAM;";

$result = mysql_query($query);
// check it it was succesfull
if ($result == 1){
$resultReturner .= "<tr><th>Creation of players table</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Creation of players table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";
}

//
//Vastustaja omat pelaajat taulu
//
$query = "CREATE TABLE ".$DBprefix."players_opponent (
PlayerID int(10) unsigned NOT NULL default '0',
OpponentID smallint(4) unsigned NOT NULL default '0',
KEY PlayerID (PlayerID),
KEY OpponentID (OpponentID)
) TYPE=MyISAM;";
$result = mysql_query($query);
// check it it was succesfull
if ($result == 1){
$resultReturner .= "<tr><th>Creation of players_opponent table</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Creation of players_opponent table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";
}


//
//Asetukset taulu
//
$query = "CREATE TABLE ".$DBprefix."preferences (
ID int(10) unsigned NOT NULL default '0',
TeamName varchar(128) NOT NULL default '',
DefaultSeasonID int(11) NOT NULL default '0',
DefaultMatchTypeID int(11) NOT NULL default '0',
DefaultLanguage int(10) unsigned NOT NULL default '0',
PRIMARY KEY (ID)
) TYPE=MyISAM;";
$result = mysql_query($query);
// check it it was succesfull
if ($result == 1)
{
$resultReturner .= "<tr><th>Creation of preferences table</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Creation of preferences table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";
}
// check if there isn't any data in the table.
$query3 = "Select * from ".$DBprefix."preferences where ID='1'";
$result3 = mysql_query($query3);
if ($row3 = mysql_fetch_array($result3)){
$resultReturner .= "<tr><th>Creation of preferences</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>There are preferences already installed</td></tr>";
}else{
// create the matchplace home and away
$query2 = "INSERT INTO ".$DBprefix."preferences (ID, TeamName, DefaultSeasonID, DefaultMatchTypeID, DefaultLanguage) VALUES ('0', '$team', '1', '1', '1')";
$result2 = mysql_query($query2);
// check it it was succesfull
if ($result2 == 1){
$resultReturner .= "<tr><th>Insertion of Preferences</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Insertion of Preferences</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";}
}



//
//Punaiset kortit-taulu
//
$query = "CREATE TABLE ".$DBprefix."redcards (
RedCardID int(10) unsigned NOT NULL auto_increment,
RedCardPlayerID int(10) unsigned NOT NULL default '0',
RedCardMatchID int(10) unsigned NOT NULL default '0',
RedCardSeasonID int(10) unsigned NOT NULL default '0',

RedCardMinute tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (RedCardID),
KEY RedCardPlayerID (RedCardPlayerID),
KEY RedCardMatchID (RedCardMatchID),
KEY RedCardSeasonID (RedCardSeasonID)
) TYPE=MyISAM;";
$result = mysql_query($query);
// check it it was succesfull
if ($result == 1){
$resultReturner .= "<tr><th>Creation of redcards table</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Creation of redcards table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td></tr>";
}

//
//Kausien nimet taulu
//
$query = "CREATE TABLE ".$DBprefix."seasonnames (
SeasonID int(10) unsigned NOT NULL auto_increment,
SeasonName varchar(64) NOT NULL default '',
SeasonPublish tinyint(1) unsigned NOT NULL default '1',
PRIMARY KEY (SeasonID)
) TYPE=MyISAM;";
$result = mysql_query($query);
// check it it was succesfull
if ($result == 1){
$resultReturner .= "<tr><th>Creation of seasonnames table</th><td><img src="../assets/images/icon_ok.gif" height="16" width="16" title="SUCCESSFUL" /></td></tr>";
}else{
// if it wasn't succesfull print the errornumer (with mysql_errno()) and an description of the error (with mysql_error())
$resultReturner .= "<tr><th>Creation of seasonnames table</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>Errornumber ". mysql_errno() .": "". mysql_error() .""</td>";
}
// check if there isn't any data in the table.
$query3 = "Select * from ".$DBprefix."seasonnames where ID='1'";
$result3 = mysql_query($query3);
if ($row3 = mysql_fetch_array($result3)){ //906
$resultReturner .= "<tr><th>Insertion of Current Season Name</th><td><img src="../assets/images/icon_cancel.gif" height="16" width="16" title="ERROR" /></td><td>There are Seasons already installed</td></tr>";
[/code]
Copy linkTweet thisAlerts:
@NogDogJan 17.2006 — [i]Please[/i] use my suggestion of using the "or die()" at the end of [i]each[/i] mysql_query() command so that you can get some useful debug information. You'll save yourself (and us) a lot of time.
<i>
</i>$result = mysql_query($query) [b][color=red]or die("Query: $query -- Error: ".mysql_error())[/color][/b];
×

Success!

Help @solidariti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...