Jump to content

Unknown column 'OpponentMAP' in 'field list' error


Recommended Posts

Hi, I'm a bit new to all this so apolagies if its a stupid question! I've searched the forum but can't really seem to find an answer for my topic.

 

(Also, sorry for the really long chunk of coding! I just dont have a clue  :-[ )

 

When trying to insert data i get the error: 'Unknown column 'OpponentMAP' in 'field list'

 

Can anyone help, much appreciated :)

 

efine( "IMG_DIR", "../images/" );

define( "IMG_SDIR", "../images/" );

 

//Tarkistetaan sessio_id

if(!isset($sessioid) || $sessioid != "$sessio")

{

print("Authorization failed.<br>

<a href=\"index.php\">Restart, please</a>");

}

else

{

//Connect to the database and select used database

include('user.php');

$connection = mysql_connect("$host","$user","$password")

or die(mysql_error());

mysql_select_db("$txt_db_name",$connection)

or die(mysql_error());

 

$seasonid = $_SESSION['season_id];

$seasonname = $_SESSION['season_name'];

 

$PHP_SELF = $_SERVER['PHP_SELF'];

$HTTP_REFERER = $_SERVER['HTTP_REFERER'];

$action = $_REQUEST['action'];

 

$add_submit = $_POST['add_submit'];

$modify_submit = $_POST['modify_submit'];

$delete_submit = $_POST['delete_submit'];

 

 

if($add_submit)

{

$opponent = trim($_POST['opponent']);

 

//Tarkistetaan, että kannasta ei löydy aiempia samannimisiä vastustajia

$query = mysql_query("SELECT OpponentName FROM KYL_opponents WHERE OpponentName = '$opponent'",$connection)

or die(mysql_error());

 

if(mysql_num_rows($query) > 0)

{

echo "There is already opponent named: $opponent in database.";

exit();

}

 

mysql_free_result($query);

 

if($opponent != '')

{

mysql_query("INSERT INTO KYL_opponents SET OpponentName = '$opponent'",$connection)

or die(mysql_error());

 

header("Location: $PHP_SELF?sessioid=$sessio");

}

}

elseif($modify_submit)

{

$opponent = trim($_POST['opponent']);

$www = str_replace('http://', '', trim($_POST['www']));

$map = str_replace('http://', '', trim($_POST['map']));

$directions = str_replace('http://', '', trim($_POST['directions']));

$fiveday = str_replace('http://', '', trim($_POST['fiveday']));

$info = str_replace("\r\n", '<br>', trim($_POST['info']));

$opponentid = $_POST['opponentid'];

 

if($opponent != '')

{

mysql_query("UPDATE KYL_opponents SET

OpponentName = '$opponent',

OpponentWWW = '$www',

OpponentMAP = '$map',

OpponentDirections = '$directions',

Opponent5day = '$fiveday',

OpponentInfo = '$info'

WHERE OpponentID = '$opponentid'",$connection)

or die(mysql_error());

 

                        if( is_array( $_POST['_opp'] ) )

                        {

                                $query = "UPDATE KYL_opponents SET ";

                                foreach( $_POST['_opp'] as $f => $v )

                                        $query .= ($f . "='" . addslashes($v) . "',");

                                $query .= "OpponentID='$opponentid' WHERE OpponentID='$opponentid'";

                                mysql_query($query) or die(mysql_error());

                        }

 

                        function UploadImg( $imgname, $opponentid )

                        {

                                if( $_POST['img' . $imgname . 'act'] == 0 ) {}

                                if( $_POST['img' . $imgname . 'act'] == 2 )

                                {

                                        $query = "UPDATE KYL_opponents SET Opponent" . $imgname . "='' WHERE OpponentID='$opponentid'";

                                        mysql_query($query) or die(mysql_error());

                                }

                                if( $_POST['img' . $imgname . 'act'] == 1 && @is_uploaded_file( $_FILES['img' . $imgname]['tmp_name'] ) )

                                {

                                        $newfilename = 'opponent' . strtolower($imgname) . '_' . $opponentid;

                                        if(  $_FILES['img' . $imgname]['type'] == 'image/gif' ) $newfilename .= ".gif";

                                        if(  $_FILES['img' . $imgname]['type'] == 'image/pjpeg' ) $newfilename .= ".jpg";

                                        if( move_uploaded_file( $_FILES['img' . $imgname]['tmp_name'], IMG_DIR . $newfilename ) )

                                        {

                                                //echo "HERE";

                                                $query = "UPDATE KYL_opponents SET Opponent" . $imgname . "='".$newfilename."' WHERE OpponentID='$opponentid'";

                                                mysql_query($query) or die(mysql_error());

                                        }

                                }

                                return;

                        }

 

                        UploadImg( "Logo", $opponentid );

                        UploadImg( "Ground", $opponentid );

 

}

 

header("Location: $HTTP_REFERER");

}

elseif($delete_submit)

{

The error tells you everything: the field, OpponentMAP doesn't exist. Is it supposed to exist?

 

If the error you've posted is generated by the above code, then it would seem that $imgname most contain the string 'MAP', since you dont actually use the field OpponentMAP anywhere, but you add that variable onto the end of 'Opponent'.

Well, if you run the query:

 

ALTER TABLE KYL_opponents ADD OpponentMAP VARCHAR( 255 ) NOT NULL ;

 

You'll create the field called OpponentMAP. Or you can do it through phpMyAdmin if you have access to it.

 

Wether or not that is going to make everything work, i couldn't tell you - the missing field in the database could just be the start of your problems. Since you're missing at least this field, i assume you didn't create the code yourself? It might be better to contact the person that made this if you're having issues.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.