Jump to content

Error itemshop add item


Recommended Posts

  • Honorable Member

Maybe because it's SQL? :D

 

Your current query should look like this:

INSERT INTO workorders VALUES ($column1, $column2);

so you have to add "(column1, column2)" to it.

INSERT INTO workorders (column1, column2) VALUES ($column1, $column2)

 

Replace column1/column2/... with your columns of your table in which you want to insert the values. If you need more help please post your php code.

Link to comment
Share on other sites

2 minutes ago, .PolluX said:

Maybe because it's SQL? :D

 

Your current query should look like this:


INSERT INTO workorders VALUES ($column1, $column2);

so you have to add "(column1, column2)" to it.


INSERT INTO workorders (column1, column2) VALUES ($column1, $column2)

 

Replace column1/column2/... with your columns of your table in which you want to insert the values. If you need more help please post your php code.

This is it.

This is the hidden content, please

  • Metin2 Dev 1
  • Good 1
  • Love 1
Link to comment
Share on other sites

1 minute ago, .PolluX said:

When you're an administrator and want to download an attachment and the forum shows you...


The page you are trying to access is not available for your account. 

 

Could you please post it inside a code tag or put it on pastebin.com?

Yes of course.
http://pastebin.com/TjFhaV5A

Link to comment
Share on other sites

  • Honorable Member

Replace line 48-51

$sqlCmd="INSERT INTO ".SQL_HP_DB.".is_items
          (vnum, kategorie_id, bild, beschreibung, preis, anzeigen, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, socket0, socket1, socket2)
          VALUES
          ('".$inVnum."','".$inKategorie."','".$bildDatei."','".$inBeschreibung."','".$inPreis."','".$inAnzeigen."','".$boni0."', '".$boniv0."', '".$boni1."', '".$boniv1."', '".$boni2."', '".$boniv2."', '".$boni3."', '".$boniv3."', '".$boni4."', '".$boni4."', '".$boni5."', '".$boniv5."', '".$boni6."', '".$boniv6."', '".$socket0."', '".$socket1."', '".$socket1."')";

with

$sqlCmd="INSERT INTO ".SQL_HP_DB.".is_items
          (kategorie_id, bild, beschreibung, preis, anzeigen, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, socket0, socket1, socket2)
          VALUES
          ('".$inKategorie."','".$bildDatei."','".$inBeschreibung."','".$inPreis."','".$inAnzeigen."','".$boni0."', '".$boniv0."', '".$boni1."', '".$boniv1."', '".$boni2."', '".$boniv2."', '".$boni3."', '".$boniv3."', '".$boni4."', '".$boni4."', '".$boni5."', '".$boniv5."', '".$boni6."', '".$boniv6."', '".$socket0."', '".$socket1."', '".$socket1."')";

and try again.

Link to comment
Share on other sites

8 minutes ago, .PolluX said:

 

8 minutes ago, .PolluX said:

Replace line 48-51


$sqlCmd="INSERT INTO ".SQL_HP_DB.".is_items
          (vnum, kategorie_id, bild, beschreibung, preis, anzeigen, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, socket0, socket1, socket2)
          VALUES
          ('".$inVnum."','".$inKategorie."','".$bildDatei."','".$inBeschreibung."','".$inPreis."','".$inAnzeigen."','".$boni0."', '".$boniv0."', '".$boni1."', '".$boniv1."', '".$boni2."', '".$boniv2."', '".$boni3."', '".$boniv3."', '".$boni4."', '".$boni4."', '".$boni5."', '".$boniv5."', '".$boni6."', '".$boniv6."', '".$socket0."', '".$socket1."', '".$socket1."')";

with


$sqlCmd="INSERT INTO ".SQL_HP_DB.".is_items
          (kategorie_id, bild, beschreibung, preis, anzeigen, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, socket0, socket1, socket2)
          VALUES
          ('".$inKategorie."','".$bildDatei."','".$inBeschreibung."','".$inPreis."','".$inAnzeigen."','".$boni0."', '".$boniv0."', '".$boni1."', '".$boniv1."', '".$boni2."', '".$boniv2."', '".$boni3."', '".$boniv3."', '".$boni4."', '".$boni4."', '".$boni5."', '".$boniv5."', '".$boni6."', '".$boniv6."', '".$socket0."', '".$socket1."', '".$socket1."')";

and try again.

This error is because i try to add items into itemshop. Now i don't get an error but the item not added. Can you help me?

Link to comment
Share on other sites

  • Honorable Member

Check if your table "is_items" has a field "vnum" with AUTO_INCREMENT flag enabled.

 

Additionally add

ini_set('display_errors', 1);

on line 2, over

error_reporting(E_ALL);

 

to check if there really isn't any php error.

 

Then replace on line 53

if($inSql) echo'<p class="meldung">Item erfolgreich in den Itemshop eingef&uuml;gt.</p>';

with

if($inSql){
	echo'<p class="meldung">Item erfolgreich in den Itemshop eingefügt.</p>';
}else{
	echo mysql_errno($sqlHp) . ": " . mysql_error($sqlHp) . "\n";
}

and run the script again.

Link to comment
Share on other sites

1 hour ago, .PolluX said:

When you're an administrator and want to download an attachment and the forum shows you...


The page you are trying to access is not available for your account. 

 

Im not administrator and i can see the same error.

93a3df11d0acdc110e1217026ee137e2.png

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

ok i just didnt read the whole code section but i noticed something wrong so please fix that first:

$boni0 = ($_POST['boni0']>=0 && $_POST['boni0']<=255) ? $_POST['boni0'] : '0';
$boni1 = ($_POST['boni1']>=0 && $_POST['boni1']<=255) ? $_POST['boni1'] : '0';
$boni2 = ($_POST['boni2']>=0 && $_POST['boni2']<=255) ? $_POST['boni2'] : '0';
$boni3 = ($_POST['boni3']>=0 && $_POST['boni3']<=255) ? $_POST['boni3'] : '0';
$boni4 = ($_POST['boni4']>=0 && $_POST['boni4']<=255) ? $_POST['boni4'] : '0';
$boni5 = ($_POST['boni5']>=0 && $_POST['boni5']<=255) ? $_POST['boni5'] : '0';
$boni6 = ($_POST['boni6']>=0 && $_POST['boni6']<=255) ? $_POST['boni6'] : '0';

in this if statements is the else part not an integer because you put 0 into '0'. Try it like this:

$boni0 = ($_POST['boni0']>=0 && $_POST['boni0']<=255) ? $_POST['boni0'] : 0;
$boni1 = ($_POST['boni1']>=0 && $_POST['boni1']<=255) ? $_POST['boni1'] : 0;
$boni2 = ($_POST['boni2']>=0 && $_POST['boni2']<=255) ? $_POST['boni2'] : 0;
$boni3 = ($_POST['boni3']>=0 && $_POST['boni3']<=255) ? $_POST['boni3'] : 0;
$boni4 = ($_POST['boni4']>=0 && $_POST['boni4']<=255) ? $_POST['boni4'] : 0;
$boni5 = ($_POST['boni5']>=0 && $_POST['boni5']<=255) ? $_POST['boni5'] : 0;
$boni6 = ($_POST['boni6']>=0 && $_POST['boni6']<=255) ? $_POST['boni6'] : 0;

same for $boniv0, $boniv1, $boniv2, $boniv3, $boniv4, $boniv5 and $boniv6

you can check every input with this to avoid strings:

var_dump(is_int($var));

Link to comment
Share on other sites

3 minutes ago, Ayaka said:

ok i just didnt read the whole code section but i noticed something wrong so please fix that first:


$boni0 = ($_POST['boni0']>=0 && $_POST['boni0']<=255) ? $_POST['boni0'] : '0';
$boni1 = ($_POST['boni1']>=0 && $_POST['boni1']<=255) ? $_POST['boni1'] : '0';
$boni2 = ($_POST['boni2']>=0 && $_POST['boni2']<=255) ? $_POST['boni2'] : '0';
$boni3 = ($_POST['boni3']>=0 && $_POST['boni3']<=255) ? $_POST['boni3'] : '0';
$boni4 = ($_POST['boni4']>=0 && $_POST['boni4']<=255) ? $_POST['boni4'] : '0';
$boni5 = ($_POST['boni5']>=0 && $_POST['boni5']<=255) ? $_POST['boni5'] : '0';
$boni6 = ($_POST['boni6']>=0 && $_POST['boni6']<=255) ? $_POST['boni6'] : '0';

in this if statements is the else part not an integer because you put 0 into '0'. Try it like this:


$boni0 = ($_POST['boni0']>=0 && $_POST['boni0']<=255) ? $_POST['boni0'] : 0;
$boni1 = ($_POST['boni1']>=0 && $_POST['boni1']<=255) ? $_POST['boni1'] : 0;
$boni2 = ($_POST['boni2']>=0 && $_POST['boni2']<=255) ? $_POST['boni2'] : 0;
$boni3 = ($_POST['boni3']>=0 && $_POST['boni3']<=255) ? $_POST['boni3'] : 0;
$boni4 = ($_POST['boni4']>=0 && $_POST['boni4']<=255) ? $_POST['boni4'] : 0;
$boni5 = ($_POST['boni5']>=0 && $_POST['boni5']<=255) ? $_POST['boni5'] : 0;
$boni6 = ($_POST['boni6']>=0 && $_POST['boni6']<=255) ? $_POST['boni6'] : 0;

 

I did what you said but again the same. Nothing happens.

Link to comment
Share on other sites

Problem solved. It was the variable type. if someone else will have this problem be sure to convert all variables into integer if your column type is int! 

/* you can to that this way */
intval($var);
/* or like this */
(int)$var

PS: Keep in mind that .PolluX was removing the value for vnum in the query, which was AUTO_INCREMENT and part of fixing this issue: 

 

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.