Jump to content

[SOLVED] Check mysql database for data


monkeybidz

Recommended Posts

<?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 ;}
?>

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();
}

?>

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.

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';
}

   

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

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";

?> 

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();
}

:D

 

Thanks for the help guys. Could not have done it without you.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.