Locked Posted September 3, 2007 Share Posted September 3, 2007 I dont know how to explain it so ill show you the code $select=$q("SELECT UserExp.CrimeExp, User.Nerve, CrimeList.ExpNeeded, CrimeList.ExpGain, CrimeList.ExpLoss, CrimeType.Nerve FROM UserExp,User,CrimeList,CrimeType where CrimeList.CrimeID=CrimeType.ID AND CrimeType.ID='$_GET[type]'")or die(mysql_error()); $select=mysql_fetch_array($select); $Test=$select[user.Nerve]; $Test2=$select[CrimeType.Nerve]; echo("Test: $Test Test2: $Test2 "); if($select[user.Nerve]<$select[CrimeType.Nerve]){ Basicly there both returning null, any advice in getting around this problem Quote Link to comment https://forums.phpfreaks.com/topic/67792-solved-mysql-joins/ Share on other sites More sharing options...
Locked Posted September 4, 2007 Author Share Posted September 4, 2007 >.< Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/67792-solved-mysql-joins/#findComment-341418 Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 You should put "type" in quotes in the $_GET[] array. I'm not sure it will change anything, but it is a literal string in the array, so it should be called as such. You will need curly braces too, if you do that. ...CrimeType.ID='{$_GET['type']}'")... If that doens't fix anything, post the layout of the tables with some sample data and what you are trying to get the query to return. Quote Link to comment https://forums.phpfreaks.com/topic/67792-solved-mysql-joins/#findComment-341423 Share on other sites More sharing options...
Locked Posted September 4, 2007 Author Share Posted September 4, 2007 I think the problem is that the both tables have a feild called 'nerve' in it, when i call from the exact same query i use $select[CrimeExp] but because theres 2 nerve feilds i tryed using TableName.Feild both turns out null leading me to belive that the name is wrong, everything else works just the nerve turns out null <?php $select=$q("SELECT UserExp.CrimeExp, User.Nerve, CrimeList.ExpNeeded, CrimeList.ExpGain, CrimeList.ExpLoss, CrimeType.Nerve FROM UserExp,User,CrimeList,CrimeType where CrimeList.CrimeID=CrimeType.ID AND CrimeType.ID='$_GET[type]'")or die(mysql_error()); $select=mysql_fetch_array($select); $Test=$select[user.Nerve]; $Test2=$select[CrimeType.Nerve]; echo("Test: $Test Test2: $Test2 "); if($select[user.Nerve]<$select[CrimeType.Nerve]){ if($select[CrimeExp]>=$select[ExpNeeded])$pass=rand(0,13); else $pass=rand(0,6); $pass1=rand(1,3); echo $pass; if($pass>=7){//Passed $exp=$select[ExpNeeded]*2; $ExpGain=$select[ExpGain]/2; $ExpGain=rand($ExpGain,$select[ExpGain]); $pass='CrimeList.Good'.$pass1; $select=$q("SELECT UserExp.CrimeExp, $pass , CrimeList.MoneyGain, CrimeList.JewelGain, CrimeList.ItemGain, CrimeType.Nerve FROM UserExp ,CrimeList,CrimeType where CrimeList.CrimeID=CrimeType.ID AND CrimeType.ID='$_GET[type]'")or die(mysql_error()); ?> Everything there works just both nerves turn out blank Quote Link to comment https://forums.phpfreaks.com/topic/67792-solved-mysql-joins/#findComment-341482 Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 One of the SELECTs with the nerve field needs to define it as a different name. "SELECT User.Nerve, CrimeType.Nerve as CTNerve FROM..."; Then you can use Nerve as the one from User and CTNerve as the one from CrimeType. You could even set User.Nerve as UNerve, or something, if you wanted. Quote Link to comment https://forums.phpfreaks.com/topic/67792-solved-mysql-joins/#findComment-341513 Share on other sites More sharing options...
Locked Posted September 4, 2007 Author Share Posted September 4, 2007 Thanks i have never seen the as statement before =) Quote Link to comment https://forums.phpfreaks.com/topic/67792-solved-mysql-joins/#findComment-341620 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.