DaVuLf Posted March 18, 2007 Share Posted March 18, 2007 Hey there. I'm having an issue with the following set of commands: //Check to see if we already have an entry for the acquiror stock $acquiror_existence_query = "SELECT * FROM portfolio WHERE team='$team_name' AND stock='$acquiror' AND flag='0'"; echo $acquiror_existence_query.'<br />'; $acquiror_existence = mysql_query($acquiror_existence_query) or die(mysql_error()); echo $acquiror_existence.'<br />'; if($acquiror_existence){ //Check to see the value of these shares $acquiror_value = mysql_result($acquiror_existence,0,"value"); //Check the quantity that they have $acquiror_quantity = mysql_result($acquiror_existence,0,"quantity"); } else { //If it doesn't exist, set it to 0. $acquiror_value = 0; $acquiror_quantity = 0; } Most specifically, this is happening because I am running a check to see if $acquiror_existence is true (ie, it exists) then running the appropriate segment of the if statement. Here is the results of my echoes. SELECT * FROM portfolio WHERE team='bcom4' AND stock='MRK' AND flag='0' Resource id #15 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 15 in C:\Program Files\xampp\htdocs\wdt\events.php on line 109 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 15 in C:\Program Files\xampp\htdocs\wdt\events.php on line 111 For some reason this is giving me some errors. I don't quite understand, but if someone could clarify, or help out, that would be fantastic. As it is, the string that it is looking for is not actually in the 'portfolio' table. There is no line with that description, as a result it should return the error, and then it should follow into the 'else' segment of the if statement, as acquiror_existence would be switched to 'false'. Thanks for any help, DaVuLF Quote Link to comment https://forums.phpfreaks.com/topic/43208-solved-or-die-isnt-working-properly-i-think/ Share on other sites More sharing options...
Barand Posted March 18, 2007 Share Posted March 18, 2007 Your assumption that mysql_query() returns an error if no rows are found is the problem. Finding no matches is a valid result. To check if rows are returned if(mysql_num_rows($acquiror_existence) > 0) Quote Link to comment https://forums.phpfreaks.com/topic/43208-solved-or-die-isnt-working-properly-i-think/#findComment-209828 Share on other sites More sharing options...
DaVuLf Posted March 18, 2007 Author Share Posted March 18, 2007 Thanks Barand. I hadn't thought of that. Quote Link to comment https://forums.phpfreaks.com/topic/43208-solved-or-die-isnt-working-properly-i-think/#findComment-209869 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.