darkfreaks Posted October 8, 2007 Share Posted October 8, 2007 <?php ///if uid not equal sblist and set to yes if($softbiz_sbid_listz!=$uid || $sb_private == 'Yes'){ header("Location: gen_confirm.php?errmsg=".urlencode ("This user has profile set to private. Only friends can view this page. <BR><a href=addme_request.php? >Click here to request to be added.</a>")); die(); } ///if set to no and it matches to display the profile elseif ($softbiz_sbid_listz=$uid || $sb_private == 'No'){ other code here ;} ?> Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364344 Share on other sites More sharing options...
monkeybidz Posted October 8, 2007 Author Share Posted October 8, 2007 What would i use there? The user will just see the current page instead of heading to error page. Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364357 Share on other sites More sharing options...
darkfreaks Posted October 8, 2007 Share Posted October 8, 2007 switch it around then <?php ///if set to no and it matches to display the profile if ($softbiz_sbid_listz=$uid || $sb_private == 'No'){ } elseif($softbiz_sbid_listz!=$uid || $sb_private == 'Yes'){ header("Location: gen_confirm.php?errmsg=".urlencode ("This user has profile set to private. Only friends can view this page. <BR><a href=addme_request.php? >Click here to request to be added.</a>")); die(); } ?> Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364362 Share on other sites More sharing options...
darkfreaks Posted October 8, 2007 Share Posted October 8, 2007 leave it blank it would do nothing if it matched if it doesnt match it will error and redirect you to whatever page Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364369 Share on other sites More sharing options...
monkeybidz Posted October 8, 2007 Author Share Posted October 8, 2007 I just noticed sb_id in both tables "sbdtng_members & sbdtng_favorites" is present, but in members is $idsoftbidz and in favorites it represents row number or different id. Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364373 Share on other sites More sharing options...
darkfreaks Posted October 8, 2007 Share Posted October 8, 2007 would that effect the code? ??? Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364374 Share on other sites More sharing options...
monkeybidz Posted October 8, 2007 Author Share Posted October 8, 2007 Yes, we are asking for sd_id to = $idsoftbiz which would give us the id for the owner of the page. This would be found in Table sbdtng_members. In sbdtng_favorites, sb_id = a row or line number which will vary depending on the number of friends created by users. it is a whole entirely diffrent deal. So the code we used at first would probably have worked without selecting sb_id. Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364388 Share on other sites More sharing options...
darkfreaks Posted October 8, 2007 Share Posted October 8, 2007 then try that and see if it works? ??? Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-364391 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 OK, the creators of the script will take too long to customize it for me. I tried this query directly in the Mysql and it works. What i don't know how to do is get the rows for this query. I now know that the number of rows have to be 2 for this query. How do i change this code to where -- if sql rows are less than 2 && sb_private =='Yes' return the error. Lets use $ret & $row. ??? This should be easy for you guys. $uid=$_SESSION["sbdtng_userid"]; $sql='SELECT * FROM `sbdtng_favorites` WHERE `sb_uid`=$idsoftbiz AND `sb_offer_id`=$uid'; if(--SQL-ROWS-DO-NOT-EQUAL-2 && $sb_private == 'Yes'){ header("Location: gen_confirm.php?errmsg=".urlencode("This user has profile set to private. Only friends can view this page.<BR><a href=addme_request.php? >Click here to request to be added.</a>")); die(); }else{ $sb_private == 'No'; } Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365863 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 <?php $num_rows=mysql_num_rows($result); if( $num_rows!=2|| $sb_private == 'Yes'){ ?> Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365878 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 What do i use for $result? Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365880 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 the sql variable Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365882 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 Is this Ok? $result=mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365884 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 thats fine as long as you dont have mysql_query in your sql variable Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365885 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 Well, i get this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365887 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 replace mysql_num_rows with either mysql_fetch_array or mysql_fetch_assoc and let me know what it turns up? Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365889 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 mysql_fetch_array returned: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource mysql_fetch_assoc returned: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365891 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 Edit: that wont work either your query is wrong! it needs to be like i said earlier <?php $sql=mysql_query('insert stff here'); $num_rows= mysql_num_rows($sql); ?> Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365892 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 Still get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365897 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 code and line number? Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365898 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 Line 33 which is: $num_rows=mysql_num_rows($sql); Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365908 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 oh i remember why you need to also have a connection so like <?php $link = mysql_connect("localhost", "mysql_user", "mysql_password"); mysql_select_db("database", $link); $result = mysql_query("SELECT * FROM table1", $link); $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; ?> Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365909 Share on other sites More sharing options...
monkeybidz Posted October 10, 2007 Author Share Posted October 10, 2007 I got it! It's about time. $uid=$_SESSION["sbdtng_userid"]; $sql="SELECT * FROM `sbdtng_favorites` WHERE `sb_uid`=$idsoftbiz AND `sb_offer_id`=sb_offer_id"; $sql2="SELECT * FROM `sbdtng_members` WHERE `sb_id`=$idsoftbiz AND `sb_private`=`sb_private`"; $row=mysql_fetch_array(mysql_query($sql)); $row2=mysql_fetch_array(mysql_query($sql2)); $sb_offer_id=$row["sb_offer_id"]; $sb_private=$row2["sb_private"]; if($sb_offer_id != $uid && $sb_private == 'Yes'){ header("Location: gen_confirm.php?errmsg=".urlencode("This user has profile set to private. Only friends can view this page.<BR><a href=addme_request.php? >Click here to request to be added.</a>")); die(); } Thanks for the help guys. Could not have done it without you. Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365954 Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 congratz you did something yourself Link to comment https://forums.phpfreaks.com/topic/72123-solved-check-mysql-database-for-data/page/2/#findComment-365969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.