zhshero Posted November 21, 2010 Share Posted November 21, 2010 Can someone help me get this working <?php include "sessionStore.php"; $userfinal = get_username($_SESSION['user_id']); if ($userfinal[username]) { //checks user is logged in switch ($_GET[friends]) { //allows multiple pages default: $get = mysql_query( "SELECT * FROM `friend_requests` WHERE `username` = '$userfinal' "); //gets requests while ($reqs = mysql_fetch_array($get)) { echo ( "Friend Requests $reqs[by] wants to be friends with you. <a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/> <a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links } break; case 'accept': //accept page if ($_GET[user]) { //get username $add = mysql_query( "INSERT INTO `friends` (`friendname` , `username`, `added`) VALUES ('$_GET[user]' , '$userfinal' , '1') "); // add to your friends list $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user] has been added as a friend and the request has been deleted" ); // echos the completion } break; //ends accept page case 'delete': // delete page if ($_GET[user]) { //gets username $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user]'s request has been deleted" ); // echos completion } break; //ends delete page } // ends switch } else { echo ( "You need to be logged in" ); // not logged in } ?> Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/ Share on other sites More sharing options...
Rifts Posted November 21, 2010 Share Posted November 21, 2010 your joking right? Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/#findComment-1137332 Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Are we supposed to guess what does not work? Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/#findComment-1137341 Share on other sites More sharing options...
zhshero Posted November 21, 2010 Author Share Posted November 21, 2010 sorry this supposed to grab friend requests from the database it for accepting new friends or deleting the friend request but when i click accept i notice that url to accept that user isn't working right <a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/> <a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links its jsut showing up like this newfriends.php?friends=delete&user= when there should be a username beside $user=<username> Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/#findComment-1137344 Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 If your column name is "by" in Mysql, try using $reqs['by'] Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/#findComment-1137350 Share on other sites More sharing options...
shlumph Posted November 21, 2010 Share Posted November 21, 2010 That means that $reqs[by] is NULL. Can you think of why that would be happening? Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/#findComment-1137352 Share on other sites More sharing options...
zhshero Posted November 21, 2010 Author Share Posted November 21, 2010 well all i know is when i last tested the code, it worked fine, but now i was just testing again to make sure it work, well it was doing that i haven't edited anything :S im checking my database to see if it missed anything while inserting data into mysql Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/#findComment-1137357 Share on other sites More sharing options...
zhshero Posted November 21, 2010 Author Share Posted November 21, 2010 takes forever to load phpmyadmin -,- i beleive there nothign wrong with that code since it failed to insert by into the database <? include "sessionStore.php"; $Username = $_GET['username']; $user = mysql_query("SELECT * FROM users WHERE Username = '$Username'"); $user=mysql_fetch_assoc($user); $userfinal = get_username($_SESSION['user_id']); $by = $userfinal; //you $query = mysql_query("INSERT INTO `friend_requests` ( `username` , `by` ) VALUES ( '$Username' , '$by' )"); //inserts the request echo ( "$username has been sent a request you must now wait for it to be accepted" ); //echos completion ?> to me i don't really see a probably with this, tho it might not be secure tho Link to comment https://forums.phpfreaks.com/topic/219334-cant-get-this-working-s/#findComment-1137360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.