nothing wrong yet we are dying :(

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

nothing wrong yet we are dying :(

Post by Torniquet »

Code: Select all

$itemQuery = mysql_query("SELECT * FROM stardrome_store WHERE planet='$planet' AND colony='$colony' AND type='Healing' ORDER BY RAND() LIMIT 1");
		//
		while($row = mysql_fetch_array($itemQuery)){
			$name = $row['name'];
			$stats = $row['stats'];
			$statAdd = $row['stat_add'];
			$price = $row['price'];
			$randid = rand(1000,999999999);
			$type = $row['type'];
			$leveluse = $row['use_level'];
			$slot = $row['slot'];
		}
		
		$countQuery = mysql_query("SELECT * FROM inventory WHERE name='$name' AND id='$id'");
		$query2 = mysql_num_rows($countQuery) or die("crap");
		
		while($row = mysql_fetch_array($query)){
			
			$pqty = $row['qty'];
			$pname = $row['name'];
			
		}
the part which is failing on me is the 'mysql_num_rows'....

yet there is nothing wrong with the code 0.o

ir is there and i am missing it?
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: nothing wrong yet we are dying :(

Post by hallsofvallhalla »

the actual error would be nice

try that

Code: Select all

 $query2 = mysql_num_rows('$countQuery') or die("crap");
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: nothing wrong yet we are dying :(

Post by Torniquet »

the accual error is that it is dying and displaying "crap"
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: nothing wrong yet we are dying :(

Post by hallsofvallhalla »

and adding in the ' 's didnt help?


where is $id defined?
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: nothing wrong yet we are dying :(

Post by Torniquet »

no. adding the quote marks didnt work :(

and id is defined at the start of the script from the $_session variable.

I seem to have got round that by using the following now.

Code: Select all

$countQuery = mysql_query("SELECT * FROM inventory WHERE name='$name' AND id='$id'");
		//$query2 = mysql_num_rows('$countQuery') or die("crap");
		//$countRow = mysql_query("SELECT COUNT(*) FROM inventory WHERE name='$name' AND id='$id'");
		//$countRow = mysql_fetch_array($countRow);
		//return $countRow;
		//$counted = $countRow;
		
		while($row = mysql_fetch_array($countQuery)){
			
			$pqty = $row['qty'];
			$pname = $row['name'];
			
		}
		
		if($name != $pname){
			
			$sql = "INSERT INTO inventory (id, name, qty, stats, stat_add, price, rand_id, type, slot, use_level)
			VALUES ('$id', '$name', '1', '$stats', '$statAdd', '$price', '$randid', '$type', '$slot', '$leveluse')";

			mysql_query($sql) or die("no");
			
		}else{
			
			$qty = $pqty + 1;
			
			mysql_query("UPDATE inventory SET qty='$qty', rand_id='$randid' WHERE id='$id' AND name='$name'");
			
		}
would be nice to know why the other mesthod isnt working tho :s

it worked on another script lol.

meh welll lol. this seems to be working ok. Thanks your ya helps :D

stay tuned for my next problem :p
New Site Coming Soon! Stay tuned :D
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: nothing wrong yet we are dying :(

Post by Falken »

Torniquet wrote:the accual error is that it is dying and displaying "crap"
Not a good idea to just show crap while looking for errors. Instead use:

Code: Select all

...or die(mysql_error());
to get a nice error message instead ;)
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: nothing wrong yet we are dying :(

Post by Torniquet »

lol i did try tht... but nothing came up :( no idea why ¬¬

for some reason i still havent got the method of

$result = mysql_num_rows($query);

working....

but i have got

if(mysql_num_rows($query) > x)

working lol.

weird little thing ¬¬ lol
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: nothing wrong yet we are dying :(

Post by hallsofvallhalla »

that is strange my friend
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: nothing wrong yet we are dying :(

Post by Torniquet »

tis an annoyance lol.

BUT

aslong as it works... i dont give a rats ass tbh lol.
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: nothing wrong yet we are dying :(

Post by hallsofvallhalla »

amen
Post Reply

Return to “Coding”