...

View Full Version : Small Array Question and Query



myfayt
09-01-2011, 04:26 PM
I am using the following array below and it works fine. However I would like it to only show the ore that is greater than 0.


$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);

$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
$page .= "You gained $frow $key<br />";
}

and it displays like this


You gained 12 Copperdust
You gained 3 Lavarock
You gained 0 Turquoise
You gained 0 Fire Opal
You gained 0 Meteorite
You gained 0 Angels
You gained 0 Diamond

So I'd like it to only show the Copperdust and Lavarock since they are greater than 0 for this item.

My second question is how do I update only the values affected? My database is normalized and this is a standard update query for it.


if (mysql_num_rows($ore1query) == 1) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$orecount WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

}
else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$orecount', itemid='16', itemname='Copperdust'", "useitems");

}

Thanks

djm0219
09-01-2011, 05:14 PM
1. Alter your query to only return entries that have a value greater than zero (I guessed that the column with the value is named amount based on your second question):


$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name' AND amount > 0", 'furnace');

I'm not quite sure what you're asking in your second question.

myfayt
09-01-2011, 05:49 PM
Doesn't seem to work, because the fields are ore1, ore2, ore3, ore4, ore5, ore6, ore7. So it needs to find the amounts from each field and display only the two with numbers for that item.

I guess I need some kind of TRUE/FALSE statement block to check each field somehow.

Let me try to be clearer on the second question.


if (mysql_num_rows($ore1query) == 1) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$orecount WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

}
else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$orecount', itemid='16', itemname='Copperdust'", "useitems");

}

Itemid 16 would represent like Copperdust, it first checks to see if the user has any record of ever having any Copperdust on their account, if not it goes to the else statement and inserts a new record to their account with the amount. But if its true, it just updates it, adding the new ore to it.

So instead of doing this:


if ($frow['ore1'] > 0) {
//Add Ore
}
elseif ($frow['ore2'] > 0) {
//Add Ore
}
elseif ($frow['ore3'] > 0) {
//Add Ore
}
elseif ($frow['ore4'] > 0) {
//Add Ore
}

There has to be a simpler way with an array or something. But instead of it saying


You gained 0 Copperdust
You gained 0 Lavarock
You gained 0 Turquoise
You gained 53 Fire Opal
you gained 10 Meteorite
You gained 0 Angels
You gained 0 Diamond

and having to do a dozen checks, there should be a way to only show the ore that is greater than 0 (Which will always only be 2 types only), and update their account with those two ores, without having to do another dozen checks to see which to add.

Chris Hick
09-01-2011, 08:30 PM
NOTE: This is untested but should work.
How about putting an if statement in the foreach statement to check and see if $frow > 0, like this:



$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
}
}

myfayt
09-01-2011, 08:38 PM
That worked great, can you help me figure out the second part? I need to figure out how to extract those two into a query, without having to have all 7 in the query.

Chris Hick
09-01-2011, 08:49 PM
Why not just add the query inside an if statement that is inside a foreach statement? That way the query will only run on the ones where the frow > 0. If frow is not greater than 0, then just use an else to run the other query.



$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$orecount WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$orecount', itemid='16', itemname='Copperdust'", "useitems");

}
}

myfayt
09-01-2011, 08:58 PM
So you mean like this?


foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && $frow > 0) {

if (mysql_num_rows($ore1query) == 1) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$orecount WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

}
else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$orecount', itemid='16', itemname='Copperdust'", "useitems");
}

//NEXT

}

}
}

Chris Hick
09-01-2011, 09:49 PM
Yeah, something similiar to that. Although, in your above code, you are already in the if statement of $frow being greater than 0 so you dont have to do it again in that nested if statemnt. Also, you could place your mysql_num_rows into the statement above it.



foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && (mysql_num_rows($ore1query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$orecount WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$orecount', itemid='16', itemname='Copperdust'", "useitems");
}

//NEXT

}

}

myfayt
09-01-2011, 10:38 PM
Works perfect, one last problem, I need the piece of equipment to delete when successful. Which this line works


$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", "smithcreate");

However I had two of the same item and it deleted both of them. Any idea how I can make it only delete one of them?

Chris Hick
09-01-2011, 10:54 PM
Your best bet for that is an update. Why? Because from a previous post, your table has a column for amount correct? The issue with that is when you delete from a table, you delete an entire row, which includes all that is in that amount column. So, what you should do is an update of subtracting one from the amount.

myfayt
09-01-2011, 10:56 PM
Ah ha I think I have a plan. Is there a way to do this using mysql num rows? something like this?


if (mysql_num_rows($equip) > 1) {
//Delete or update 1 equipment
}
else {
//Delete row
}

EDIT: by the way, that old topic about having (sets) didn't happen, decided against it because there were way too many factors involved.

Chris Hick
09-01-2011, 10:59 PM
Nope, you can't do that. Because mysql_num_rows, only returns the amount of rows that meet your query's criteria, in this case just one row. You will need to query for your amount column then use that if else statement.

EDIT: Ahh, but it still does not matter. In your above queries, you clearly have a column in your table that is for amount. Which means, you can't use that myql_num_rows. You will have to do what I just said.

myfayt
09-01-2011, 11:09 PM
I don't have an amount in that table. It does have a unique id which would work, but don't have a clue how to get that to work.

Chris Hick
09-01-2011, 11:18 PM
How do you not have an amount in that table? How do you keep track of more than one of the same item? Unless, you have duplicate entries. If that is the case, then you could use the delete clause and mysql_num_rows.

myfayt
09-01-2011, 11:26 PM
People can have multiple of the same item, and it will show multiple rows of it in their inventory, but the id is always unique. This is for weapon and armor, not regular items like ores, because all those have amounts

Chris Hick
09-01-2011, 11:31 PM
Well, if that is the case, you can use your if statement with mysql_num_rows then use a delete query with a limit of 1. That will delete the first one it comes across.

myfayt
09-01-2011, 11:40 PM
So you mean like this?


if (mysql_num_rows($equip) > 1) {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", "smithcreate");
}
else {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", "smithcreate");
}

it'd be the same query, would the else statement be different?

Chris Hick
09-01-2011, 11:44 PM
Just exclude that else statement. It would be pointless to use it, unless you want to put an error message in it, in case mysql_num_rows is not greater than 1. Also, make sure $equip is the results of a query.

myfayt
09-01-2011, 11:57 PM
It's still deleting both of them.


$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name'", 'smithcreate');
if (mysql_num_rows($delquery) > 1) {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", "smithcreate");
}

Chris Hick
09-02-2011, 12:02 AM
What about using the limit 1 on the SELECT clause in your $delquery. Then, in your if statement check to see if mysql_num_rows($delquery) == 1. After, perform the delete clause.

myfayt
09-02-2011, 12:26 AM
Still deleting both after adding LIMIT 1 to the select query. What do you mean about mysql_num_rows after?

Chris Hick
09-02-2011, 12:52 AM
Well, what about this?



$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
if (mysql_num_rows($delquery) == 1) {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name="$delquery['name']" LIMIT 1", "smithcreate");
}

myfayt
09-02-2011, 02:30 AM
With that code it processes the ore, and shows the ore gained. But the delete never works. The equipment is never deleted, just gives free ore. I tried it on a single item, and double both, neither delete.

Chris Hick
09-02-2011, 03:29 AM
Sorry, fayt, in my rushing I wrote it wrong. See if that works.



$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
if (mysql_num_rows($delquery) == 1) {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $delquery['name']. " ' LIMIT 1", "smithcreate");
}

myfayt
09-02-2011, 02:22 PM
Still doesn't delete anything. Neither single or double items.
Man this is a tough bug

Chris Hick
09-02-2011, 03:20 PM
How exactly are you trying to delete these items? Are you using a form that submits in what they are using? Or are you doing something different from that?

myfayt
09-02-2011, 04:15 PM
It's just a link


<a href='furnace.php?x=burn:".urlencode($allrow['name'])."'>BURN</a>

and this is the whole function where the link processes it.


function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && (mysql_num_rows($ore1query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}

//Lavarock

if (($key == 'Lavarock') && (mysql_num_rows($ore2query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
if (($key == 'Turquoise') && (mysql_num_rows($ore3query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}

//Fire Opal
if (($key == 'Fire Opal') && (mysql_num_rows($ore4query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}

//Meteorite
if (($key == 'Meteorite') && (mysql_num_rows($ore5query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}


//Angels
if (($key == 'Angels') && (mysql_num_rows($ore6query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}

//Fire Opal
if (($key == 'Diamond') && (mysql_num_rows($ore7query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}

}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
if (mysql_num_rows($delquery) == 1) {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $delquery['name']. " ' LIMIT 1", "smithcreate");
}


}
}

Chris Hick
09-02-2011, 07:59 PM
I'm assuming your using what I suggested earlier with using the getting the variable from the url then assigning the variable name and passing it into the function burn?

Also, lets do this and see what happens:


$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $name ."' LIMIT 1", 'smithcreate');
if (mysql_num_rows($delquery) == 1) {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $delquery['name']. " ' LIMIT 1", "smithcreate");
}

myfayt
09-02-2011, 08:04 PM
Still unchanged, nothing deletes. I am wondering if instead of having it at the bottom, does it need to be moved somewhere else in the script?

Chris Hick
09-02-2011, 08:26 PM
I doubt that is the case. You could certainly do that though. I wonder, if you add an else statement after the if statement. Something like this:


$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $name ."' LIMIT 1", 'smithcreate');
if (mysql_num_rows($delquery) == 1) {
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $delquery['name']. " ' LIMIT 1", "smithcreate");
} else {
echo "<p>Nothing was deleted.</p>";
}




That way I can pinpoint the error better.

myfayt
09-02-2011, 08:36 PM
The message didn't appear, all it says is:


You gained 8 Copperdust
You gained 2 Lavarock

So it seems like its bypassing the entire delete query statement.

Chris Hick
09-02-2011, 08:46 PM
Ok, well, lets see after the $delquery,
print_r($delquery); That way we can see what it contains.

myfayt
09-02-2011, 09:40 PM
Resource id #17Resource id #18Resource id #19Resource id #20Resource id #21Resource id #22Resource id #23

Chris Hick
09-02-2011, 09:58 PM
Wait, your doquery does use mysql_fetch_array to retrieve the information doesn't it?? Because I have only seen something return a resource id when you are trying to use a mysql result without a fetch array.

myfayt
09-02-2011, 09:59 PM
I tried changing this


$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $delquery['name']. " ' LIMIT 1", "smithcreate");

to this using $name


$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", "smithcreate");

and now this is the echo, I have no idea why it's 6 times.


Resource id #17

Nothing was deleted.
Resource id #18

Nothing was deleted.
Resource id #19

Nothing was deleted.
Resource id #20

Nothing was deleted.
Resource id #21

Nothing was deleted.
Resource id #22

Nothing was deleted.

It does delete now, it works on 1 item, but it also deletes double items

Chris Hick
09-02-2011, 10:04 PM
That is because you are not using mysql_fetch_array ^_^. Do this and see what happens.


$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $name ."' LIMIT 1", 'smithcreate');
if (mysql_num_rows($delquery) == 1) {
$selection = mysql_fetch_array($delquery);
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $selection['name']. " ' LIMIT 1", "smithcreate");
} else {
echo "<p>Nothing was deleted.</p>";
}


Btw, it does it six times because you are still within that foreach!

EDIT: I just realized we could simply this and see if it works. Bear with me.



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && (mysql_num_rows($ore1query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}

//Lavarock

if (($key == 'Lavarock') && (mysql_num_rows($ore2query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
if (($key == 'Turquoise') && (mysql_num_rows($ore3query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}

//Fire Opal
if (($key == 'Fire Opal') && (mysql_num_rows($ore4query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}

//Meteorite
if (($key == 'Meteorite') && (mysql_num_rows($ore5query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}


//Angels
if (($key == 'Angels') && (mysql_num_rows($ore6query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}

//Fire Opal
if (($key == 'Diamond') && (mysql_num_rows($ore7query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}

}
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $name " ' LIMIT 1", "smithcreate");

}
}

myfayt
09-02-2011, 10:29 PM
Ok so this one doesn't delete anything.


$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $name ."' LIMIT 1", 'smithcreate');
if (mysql_num_rows($delquery) == 1) {
$selection = mysql_fetch_array($delquery);
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $selection['name']. " ' LIMIT 1", "smithcreate");
} else {
echo "<p>Nothing was deleted.</p>";
}

This one gives me a blank white page.


function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && (mysql_num_rows($ore1query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}

//Lavarock

if (($key == 'Lavarock') && (mysql_num_rows($ore2query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
if (($key == 'Turquoise') && (mysql_num_rows($ore3query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}

//Fire Opal
if (($key == 'Fire Opal') && (mysql_num_rows($ore4query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}

//Meteorite
if (($key == 'Meteorite') && (mysql_num_rows($ore5query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}


//Angels
if (($key == 'Angels') && (mysql_num_rows($ore6query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}

//Fire Opal
if (($key == 'Diamond') && (mysql_num_rows($ore7query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}

}
$query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $name " ' LIMIT 1", "smithcreate");

}
}

myfayt
09-02-2011, 10:32 PM
At this point, I believe it'd be easier to figure out a way to add a unique field to the database table. Like weapon1, weapon2, weapon3, and have the delete find that field and delete it. Since the LIMIT 1 isn't working.

Chris Hick
09-02-2011, 10:45 PM
Does this one not work??



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && (mysql_num_rows($ore1query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}

//Lavarock

if (($key == 'Lavarock') && (mysql_num_rows($ore2query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
if (($key == 'Turquoise') && (mysql_num_rows($ore3query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}

//Fire Opal
if (($key == 'Fire Opal') && (mysql_num_rows($ore4query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}

//Meteorite
if (($key == 'Meteorite') && (mysql_num_rows($ore5query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}


//Angels
if (($key == 'Angels') && (mysql_num_rows($ore6query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}

//Fire Opal
if (($key == 'Diamond') && (mysql_num_rows($ore7query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}

}
}
if ($query = doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name=' " . $name " ' LIMIT 1", "smithcreate")) {
echo "<p>" .$name . "was deleted. </p>";
}


}


As I said it would be easier to handle your weapons if you did the database as I suggested in your earlier thread. ;)

myfayt
09-02-2011, 10:55 PM
It displays Small Canewas deleted. but nothing is deleted.

I notice when it's name=' " . $name " ' it doesn't delete, but when it's $name it deletes.

I found out why it showed a blank page on that other one.

Chris Hick
09-02-2011, 11:01 PM
But you also said that using $name makes it delete doubles correct?? Or now that I have put it outside the foreach loop, does it delete doubles?

myfayt
09-02-2011, 11:41 PM
Yeah $name does delete double. I think we've tried it both ways? If you want we can setup the database the way you suggested.

Chris Hick
09-03-2011, 12:35 AM
What do the tables look like that you are querying from? (I think this would work) Ever thought of a table like -weapons- and each unique weapon has an a weaponID. Then, in your user's inventory table, so to speak, you have just the weapon ids with a sets column. Each time a user, purchases or finds an item, you check to see if they have already have purchased one, if so then add how ever many they are purchasing or found to the intial set number. If not then, you add it to the user's inventory with the amount of sets they are purchasing or found. Using a join between the weapons table and the user's inventory table, you display the user's inventory.

In theory, I think that would work O.o I could be wrong.

That was my quote from your earlier thread. I'm kinda interested in trying to solve this one for you first then, doing the database if that is what you want. lol I absolutely hate when I can't solve a problem!! lol know what I mean?

Also, can you tell me the columns that are in the tables as well as the names of the tables you are using in this function.

myfayt
09-03-2011, 01:51 AM
Yeah I'd love to solve it also. Here is the database info.

smithcreate table

id (auto increment)
type
name
attribute
requirement
bstype
class
bonusattack
playerid
equipped

furnace table

name
ore1
ore2
ore3
ore4
ore5
ore6
ore7


EDIT: Hey I wonder if I put the ores in the smithcreate, since smithcreate has a unique item per item, and just delete it from there? We should be able to extract the ore and delete the item both right?

Chris Hick
09-03-2011, 02:00 AM
Myfayt, you could certainly do that. Although, I am not too sure it would be the most efficient way to do what we are trying to do.

EDIT: Also, what does your inventory table look like?

myfayt
09-03-2011, 02:02 AM
Actually that won't work at all.

Chris Hick
09-03-2011, 02:04 AM
It would, but not the way you want it to.

EDIT: What does your inventory table look like as well?

myfayt
09-03-2011, 03:05 AM
Inventory is for items only, the smithcreate page is the inventory for equipment.

Chris Hick
09-03-2011, 03:13 AM
Oh ok, got that cleared up. So, what exactly is in the furnace table? and do you put the ores in their inventory or what?

myfayt
09-03-2011, 03:17 AM
The reason for the furnace table is solely to determine how much ore and what type they receive when they burn a weapon.

So if a weapon is 20 Copperdust and 5 Lavarock to make, to burn it they only get like 8 Copperdust and 2 Lavarock from it. A little less than half.

So the table has the names of the weapons (more equipment coming later), and which ore type and how many they would receive per that weapon.

I figured it'd be easier than to list everything in the script and cause the script to be like 3,000 lines.

Chris Hick
09-03-2011, 03:52 AM
Try this one, if this doesn't work then I'm def. going to dig in deep and figure it out!!



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && (mysql_num_rows($ore1query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}

//Lavarock

if (($key == 'Lavarock') && (mysql_num_rows($ore2query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
if (($key == 'Turquoise') && (mysql_num_rows($ore3query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}

//Fire Opal
if (($key == 'Fire Opal') && (mysql_num_rows($ore4query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}

//Meteorite
if (($key == 'Meteorite') && (mysql_num_rows($ore5query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}


//Angels
if (($key == 'Angels') && (mysql_num_rows($ore6query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}

//Fire Opal
if (($key == 'Diamond') && (mysql_num_rows($ore7query) == 1)) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");

} else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-03-2011, 02:52 PM
We're so close now. It said Small Cane was deleted. and it only deleted 1 row of the item. However it didn't give any ore. It said gained 8 Copperdust, 2 Lavarock but none was given.

Chris Hick
09-03-2011, 10:37 PM
This isn't much of a change but see what this does.



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

if (($key == 'Copperdust') && (mysql_num_rows($ore1query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");

} else {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}

//Lavarock

if (($key == 'Lavarock') && (mysql_num_rows($ore2query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");

} else {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
if (($key == 'Turquoise') && (mysql_num_rows($ore3query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");

} else {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}

//Fire Opal
if (($key == 'Fire Opal') && (mysql_num_rows($ore4query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");

} else {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}

//Meteorite
if (($key == 'Meteorite') && (mysql_num_rows($ore5query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");

} else {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}


//Angels
if (($key == 'Angels') && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");

} else {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}

//Fire Opal
if (($key == 'Diamond') && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");

} else {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-03-2011, 11:24 PM
Nope, the deleting is correct, but still no ore.

Chris Hick
09-04-2011, 07:35 AM
EDIT:

Ight, I wanna see what the results are when you use this script. I thought about it a little and using those ifs within an iteration of a for each loop just doesn't seem right. So, I went a little bit more efficient and used a switch statement.



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";

switch ($key) {
// Copperdust
case 'Copperdust' && (mysql_num_rows($ore1query) == 1):
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
break;
case 'Copperdust' && (mysql_num_rows($ore1query) == 0):
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
break;

// Lavarock
case 'Lavarock' && (mysql_num_rows($ore2query) == 1):
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
break;
case 'Lavarock' && (mysql_num_rows($ore2query) == 0):
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
break;

//Turquoise
case 'Turquoise' && (mysql_num_rows($ore3query) == 1):
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
break;
case 'Turquoise' && (mysql_num_rows($ore3query) == 0):
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
break;

//Fire Opal
case 'Fire Opal' && (mysql_num_rows($ore4query) == 1):
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
break;
case 'Fire Opal' && (mysql_num_rows($ore4query) == 0):
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
break;

//Meteorite
case 'Meteorite' && (mysql_num_rows($ore5query) == 1):
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
break;
case 'Meteorite' && (mysql_num_rows($ore5query) == 0):
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
break;

//Angels
case 'Angels' && (mysql_num_rows($ore6query) == 1):
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
break;
case 'Angels' && (mysql_num_rows($ore6query) == 0):
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
break;

//Diamond
case 'Diamond' && (mysql_num_rows($ore7query) == 1):
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
break;
case 'Diamond' && (mysql_num_rows($ore7query) == 0):
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
break;
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-04-2011, 04:06 PM
Still no ore

Chris Hick
09-04-2011, 07:25 PM
I think this may not be working because you can't have two values in a switch statement. So, as much as I like the switch statement, we might have to refer to if else if statements. Let's see if it works.


function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}
else {
echo "<p>Nothing was added to the database</p>";
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-04-2011, 08:15 PM
Nothing was added to the database

Nothing was added to the database

Small Cane was deleted.

Chris Hick
09-04-2011, 08:30 PM
Ah, so now we are getting even closer to the problem. We now know its got to do with the queries.

EDIT: So, let's try to isolate the problem even more! Try this and tell me what the result is. ;)



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// let's test to see if the keys are getting passed
if ($key == 'Copperdust') {
echo "<p>Copperdust is being passed.</p>";
} else if ($key == 'Lavarock') {
echo "<p>Lavarock is being passed.</p>";
} else if ($key == 'Turquoise') {
echo "<p>Turquoise is being passed.</p>";
} else if ($key == 'Fire Opal') {
echo "<p>Fire Opal is being passed.</p>";
} else if ($key == 'Meteorite') {
echo "<p>Meteorite is being passed.</p>";
} else if ($key == 'Angels') {
echo "<p>Angels is being passed.</p>";
} else if ($key == 'Diamonds') {
echo "<p>Diamonds is being passed.</p>";
}
/*
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}*/
else {
echo "<p>Nothing was added to the database</p>";
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-04-2011, 09:17 PM
I had to fix a small error on it, but here is the result.

Copperdust is being passed.

Lavarock is being passed.

Small Cane was deleted.

both ore types are correct.

Chris Hick
09-04-2011, 11:14 PM
Sorry, didn't mean to have those fetch arrays in there. I deleted them out of there. Anyhow, that was the results I was hoping for. We now know that the problems are the orequeries. Now, we just need to find out what is wrong with them. So, try this and tell me what the result is. :)



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// let's test to see if the keys are getting passed
if (mysql_num_rows($ore1query) == 1) {
echo "<p>Copperdust is in the inventory.</p>";
} else if (mysql_num_rows($ore1query) == 0) {
echo "<p>Copperdust is not in the inventory.</p>";
} else if (mysql_num_rows($ore2query) == 1) {
echo "<p>Lavarock is in the inventory.</p>";
} else if (mysql_num_rows($ore2query) == 0) {
echo "<p>Lavarock is not in the inventory.</p>";
}else if (mysql_num_rows($ore3query) == 1) {
echo "<p>Turquoise is in the inventory.</p>";
} else if (mysql_num_rows($ore3query) == 0) {
echo "<p>Turquoise is not in the inventory.</p>";
} else if(mysql_num_rows($ore4query) == 1) {
echo "<p>Fire Opal is in the inventory.</p>";
} else if (mysql_num_rows($ore4query) == 0) {
echo "<p>Fire Opal is not in the inventory.</p>";
}else if (mysql_num_rows($ore5query) == 1) {
echo "<p>Meteorite is in the inventory.</p>";
} else if (mysql_num_rows($ore5query) == 0) {
echo "<p>Meteorite is not in the inventory.</p>";
} else if (mysql_num_rows($ore6query) == 1) {
echo "<p>Angels is in the inventory.</p>";
} else if (mysql_num_rows($ore6query) == 0) {
echo "<p>Angels is not in the inventory.</p>";
}else if (mysql_num_rows($ore7query) == 1) {
echo "<p>Diamonds is in the inventory.</p>";
} else if (mysql_num_rows($ore7query) == 0) {
echo "<p>Diamonds is not in the inventory.</p>";
}
/*
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}*/
else {
echo "<p>Nothing was added to the database</p>";
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-04-2011, 11:26 PM
Nothing was added to the database

Nothing was added to the database

Small Cane was deleted.

Chris Hick
09-04-2011, 11:34 PM
Ok, so we know exactly what isn't getting passed now. I'm gonna try something different, because the results of this one should tell me what I need to do to fix it.



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// let's test to see if the keys are getting passed
if ($ore1query) {
echo "<p>Copperdust is in the inventory.</p>";
} else if (!$ore1query) {
echo "<p>Copperdust is not in the inventory.</p>";
} else if (ore2query) {
echo "<p>Lavarock is in the inventory.</p>";
} else if (!$ore2query) {
echo "<p>Lavarock is not in the inventory.</p>";
} else if ($ore3query) {
echo "<p>Turquoise is in the inventory.</p>";
} else if (!$ore3query) {
echo "<p>Turquoise is not in the inventory.</p>";
} else if ($ore4query) {
echo "<p>Fire Opal is in the inventory.</p>";
} else if (!$ore4query) {
echo "<p>Fire Opal is not in the inventory.</p>";
} else if ($ore5query) {
echo "<p>Meteorite is in the inventory.</p>";
} else if (!$ore5query) {
echo "<p>Meteorite is not in the inventory.</p>";
} else if ($ore6query) {
echo "<p>Angels is in the inventory.</p>";
} else if (!$ore6query) {
echo "<p>Angels is not in the inventory.</p>";
} else if ($ore7query) {
echo "<p>Diamonds is in the inventory.</p>";
} else if (!$ore7query) {
echo "<p>Diamonds is not in the inventory.</p>";
}
/*
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}*/
else {
echo "<p>Nothing was added to the database</p>";
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-04-2011, 11:53 PM
Copperdust is in the inventory.

Copperdust is in the inventory.

Small Cane was deleted.

Chris Hick
09-05-2011, 12:07 AM
Ight, I might know exactly how to fix this. But before, I put the solution that I think, I need to know what your doquery() function is. That way I can see what it is suppose to return.

myfayt
09-05-2011, 12:10 AM
That is deep in a file, it's basically just mysql_query changed to doquery, and instead of SELECT FROM users it's SELECT FROM {{table}}.

Perhaps we should just go back to something simple.

Chris Hick
09-05-2011, 12:26 AM
Well, I was wondering because I need to know if it returns data if true and returns false if there is no data.

EDIT: Ok, I know the script I'm posting below isn't very efficient, but I just wanna see what the result is.



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
/*
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems"); */
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// let's test to see if the keys are getting passed
if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is not in the inventory.</p>";
}
/*
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}*/
else {
echo "<p>Nothing was added to the database</p>";
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-05-2011, 12:42 AM
The doquery won't work like that, the way it's setup in the database it has to be a mysql_num_rows. Because when they create an account, there are no rows in the inventory. When they get an item for the first time, it create a new item row for their account for that item.

Therefor mysql_num_rows == 0 means that doesn't exist in the database at all, if it's equal to 1, that means it does and the amount could be anywhere from 0 items to the maximum number allowed.



Copperdust is in the inventory.

Copperdust is in the inventory.

Blunt Dagger was deleted.

Chris Hick
09-05-2011, 01:06 AM
Ight, then we definitely need to echo that results of all the mysql_num_rows for the orequeries. Run this script and tell me the results of the mysql_num_rows.



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);

$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);
echo mysql_num_rows($ore1query);
echo mysql_num_rows($ore2query);
echo mysql_num_rows($ore3query);
echo mysql_num_rows($ore4query);
echo mysql_num_rows($ore5query);
echo mysql_num_rows($ore6query);
echo mysql_num_rows($ore7query);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// let's test to see if the keys are getting passed
if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is not in the inventory.</p>";
}
/*
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}*/
else {
echo "<p>Nothing was added to the database</p>";
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-05-2011, 01:10 AM
There was an error in this


 

So I removed it. This is the output.


63636464646464

Copperdust is in the inventory.

Copperdust is in the inventory.

Blunt Dagger was deleted.

Chris Hick
09-05-2011, 01:36 AM
Hmm, it should be returning 1 or 0 not 63 or 64. That is very strange.

I'm going to do the row count in the sql rather than in the php. Tell me what the result is.



function burn($name)
{
global $userrow, $numqueries;
$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);

$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";
$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');
if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}
$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);
echo $ore1row = mysql_fetch_row($ore1query)"<br />";
echo $ore2row = mysql_fetch_row($ore2query)"<br />";
echo $ore3row = mysql_fetch_row($ore3query)"<br />";
echo $ore4row = mysql_fetch_row($ore4query)"<br />";
echo $ore5row = mysql_fetch_row($ore5query)"<br />";
echo $ore6row = mysql_fetch_row($ore6query)"<br />";
echo $ore7row = mysql_fetch_row($ore7query)"<br />";
foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// let's test to see if the keys are getting passed
if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is not in the inventory.</p>";
}
/*
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}
//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}*/
else {
echo "<p>Nothing was added to the database</p>";
}
}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}
}

myfayt
09-05-2011, 01:52 AM
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home2/rodgameo/public_html/furnace.php on line 103


Line 102 'Diamond' => $frow['ore7']);
Line 103 echo $ore1row = mysql_fetch_row($ore1query)"<br />";

Chris Hick
09-05-2011, 02:03 AM
Bleh, work is distracting me. Sorry about that. Do this one:



function burn($name)
{
global $userrow, $numqueries;
$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);

$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";
$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');
if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}
$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT COUNT(*) FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);
echo $ore1row = mysql_fetch_row($ore1query). "<br />";
echo $ore2row = mysql_fetch_row($ore2query). "<br />";
echo $ore3row = mysql_fetch_row($ore3query). "<br />";
echo $ore4row = mysql_fetch_row($ore4query). "<br />";
echo $ore5row = mysql_fetch_row($ore5query). "<br />";
echo $ore6row = mysql_fetch_row($ore6query). "<br />";
echo $ore7row = mysql_fetch_row($ore7query). "<br />";
foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// let's test to see if the keys are getting passed
if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems")) {
echo "<p>Copperdust is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems")) {
echo "<p>Lavarock is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems")) {
echo "<p>Turquoise is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems")) {
echo "<p>Fire Opal is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems")) {
echo "<p>Meteorite is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems")) {
echo "<p>Angels is not in the inventory.</p>";
} else if (doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is in the inventory.</p>";
} else if (!doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems")) {
echo "<p>Diamonds is not in the inventory.</p>";
}
/*
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}
//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 0)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 1)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 1)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 0)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}*/
else {
echo "<p>Nothing was added to the database</p>";
}
}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}
}

myfayt
09-05-2011, 02:24 AM
Array
Array
Array
Array
Array
Array
Array

Copperdust is in the inventory.

Copperdust is in the inventory.

Blunt Dagger was deleted.

Chris Hick
09-05-2011, 02:43 AM
I thought perhaps I would have to echo the array value.

Replace this in the code:


echo $ore1row = mysql_fetch_row($ore1query). "<br />";
echo $ore2row = mysql_fetch_row($ore2query). "<br />";
echo $ore3row = mysql_fetch_row($ore3query). "<br />";
echo $ore4row = mysql_fetch_row($ore4query). "<br />";
echo $ore5row = mysql_fetch_row($ore5query). "<br />";
echo $ore6row = mysql_fetch_row($ore6query). "<br />";
echo $ore7row = mysql_fetch_row($ore7query). "<br />";

with this:


$ore1row = mysql_fetch_row($ore1query);
$ore2row = mysql_fetch_row($ore2query);
$ore3row = mysql_fetch_row($ore3query);
echo $ore1row[0]. "<br />";
echo $ore2row[0]. "<br />";
echo $ore3row[0]. "<br />";

myfayt
09-05-2011, 02:59 AM
63
63
64

Copperdust is in the inventory.

Copperdust is in the inventory.

Small Cane was deleted.

Chris Hick
09-05-2011, 03:22 AM
Ok, we def. have to figure out why its return 63. So, what I'm going to do is perform a query like you had it before. Then, do a fetch assoc and use a foreach statement to display the amounts of each row.
Put this:
<FONT face="Courier New">

$orequery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");

$rows = mysql_fetch_assoc($ore1query);
foreach ($rows as $row) {
echo $row['amount']. "<br />";
}



right after this:


$ore1row = mysql_fetch_row($ore1query);
$ore2row = mysql_fetch_row($ore2query);
$ore3row = mysql_fetch_row($ore3query);
echo $ore1row[0]. "<br />";
echo $ore2row[0]. "<br />";
echo $ore3row[0]. "<br />";
</SPAN>
</SPAN>

myfayt
09-05-2011, 03:48 AM
63
63
64

Warning: Invalid argument supplied for foreach() in /home2/rodgameo/public_html/furnace.php on line 112

Copperdust is in the inventory.

Copperdust is in the inventory.

Small Cane was deleted.

Chris Hick
09-05-2011, 05:39 AM
Ok, this should work. Although, it still doesn't explain why your mysql_num_rows is equal to 63 if there is one in the inventory, and 64 if there isn't.



function burn($name)
{

global $userrow, $numqueries;

$townquery = doquery("SELECT `name`, `innprice` FROM `{{table}}` WHERE `latitude` = {$userrow['latitude']} AND `longitude` = {$userrow['longitude']} AND `realm` = {$userrow['realm']} LIMIT 1", 'towns');
if (mysql_num_rows($townquery) != 1)
{
display("<p>You cannot access this Area outside of town. You may now return to <a href=\"index.php\">exploring</a>.", "Error");
}
$townrow = mysql_fetch_array($townquery);


$updatequery = doquery("UPDATE {{table}} SET location='Blacksmith Furnace' WHERE id='" . $userrow["id"] . "' LIMIT 1", "users");
$title = 'Blacksmith Furnace';
$page = "<table width='100%' border='1'><tr><td class='title'><a href='index.php'>Town</a> > <a href='courtyard.php?do=main'>Courtyard</a> > <a href='furnace.php'>Blacksmith Furnace</a></td></tr></table><p>";

$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');

if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}

$frow = mysql_fetch_array($furnquery);
$ore1query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='16'", "useitems");
$ore2query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='17'", "useitems");
$ore3query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='18'", "useitems");
$ore4query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='19'", "useitems");
$ore5query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='20'", "useitems");
$ore6query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='21'", "useitems");
$ore7query = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND itemid='22'", "useitems");
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);

foreach ($arr as $key => $frow) {
if ($frow > 0) {
$page .= "You gained $frow $key<br />";
// Copperdust
if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 63)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else if($key == 'Copperdust' && (mysql_num_rows($ore1query) == 64)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='16', itemname='Copperdust'", "useitems");
}
// Lavarock
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 63)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='17' LIMIT 1", "useitems");
}
else if($key == 'Lavarock' && (mysql_num_rows($ore2query) == 64)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='17', itemname='Lavarock'", "useitems");
}

//Turquoise
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 63)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='18' LIMIT 1", "useitems");
}
else if ($key == 'Turquoise' && (mysql_num_rows($ore3query) == 64)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='18', itemname='Turquoise'", "useitems");
}
//Fire Opal
else if($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 63)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='19' LIMIT 1", "useitems");
}
else if ($key == 'Fire Opal' && (mysql_num_rows($ore4query) == 64)){
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='19', itemname='Fire Opal'", "useitems");
}
//Meteorite
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 63)){
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='20' LIMIT 1", "useitems");
}
else if ($key == 'Meteorite' && (mysql_num_rows($ore5query) == 64)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='20', itemname='Meteorite'", "useitems");
}
//Angels
else if ($key == 'Angels' && (mysql_num_rows($ore6query) == 63)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='21' LIMIT 1", "useitems");
}
else if($key == 'Angels' && (mysql_num_rows($ore6query) == 64)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='21', itemname='Angels'", "useitems");
}
//Diamond
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 63)) {
doquery("UPDATE {{table}} SET amount=amount+$frow WHERE playerid='".$userrow['id']."' AND itemid='22' LIMIT 1", "useitems");
}
else if ($key == 'Diamond' && (mysql_num_rows($ore7query) == 64)) {
doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$frow', itemid='22', itemname='Diamond'", "useitems");
}
else {
echo "<p>Nothing was added to the database</p>";
}

}
}
$delquery = doquery("SELECT * FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='$name' LIMIT 1", 'smithcreate');
$selection = mysql_fetch_array($delquery);
if (doquery("DELETE FROM {{table}} WHERE playerid='".$userrow['id']."' AND name='". $selection['name']."' LIMIT 1", "smithcreate")) {
echo "<p>" .$selection['name'] . " was deleted. </p>";
} else {
echo "<p>Nothing was deleted.</p>";
}

}

myfayt
09-05-2011, 03:43 PM
Well the good news is that it worked on the copperdust and lavarock items just fine. However I tried a turquoise and fire opal one and it didn't give me anything.

Chris Hick
09-05-2011, 08:47 PM
Ight, add this right after your $arr array and before your foreach and try using the turquoise and fire opal, then tell me what the result is.



echo mysql_num_rows($ore1query) . '<br />';
echo mysql_num_rows($ore2query) . '<br />';
echo mysql_num_rows($ore3query) . '<br />';
echo mysql_num_rows($ore4query) . '<br />';
echo mysql_num_rows($ore5query) . '<br />';
echo mysql_num_rows($ore6query) . '<br />';
echo mysql_num_rows($ore7query) . '<br />';

myfayt
09-05-2011, 09:20 PM
63
63
65
65
64
64
64

Nothing was added to the database

Nothing was added to the database

Ghost Rod was deleted.

myfayt
09-06-2011, 02:34 AM
*high five* We got it working! Thanks Chris we did it.

(I am sure everyone else on this forum is glad to see it's finally fixed)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum