Jump to content

xstevey_bx

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Everything posted by xstevey_bx

  1. I have never used cURL before but I need to use it for developing a facebook application. What I am trying to do is create a status update scheduler. There are two tables in my database. One table has generic updates for each day of the week an the other had special events. My script checks the day, checks to see if there is a special event in the future on that day, and if there is reminds guests of the upcoming event. If there is no event it posts the generic status. <?php include('config.php'); $result2 = mysql_query("select facebook_id,facebook_access_token from admin where username='users'"); $row = mysql_fetch_array($result2); $facebook_id = $row['facebook_id']; $facebook_access_token = $row['facebook_access_token']; $day = date('N'); $result2 = mysql_query("select * from events where date > CURDATE() order by date ASC") or die(mysql_error()); $num_rows = mysql_num_rows($result2); if($num_rows == 0) { $result2 = mysql_query("select * FROM alerts WHERE id='$day'") or die(mysql_error()); $row1 = mysql_fetch_array($result2); echo 'There are no events just alerts'; } else { while($row = mysql_fetch_array($result2)){ if(date('N',strtotime($row[date])) == $day) { $id = $row['id']; $result1 = mysql_query("SELECT * FROM events WHERE id = $id") or die(mysql_error()); $row1 = mysql_fetch_array($result1); } else { $result1 = mysql_query("SELECT * FROM alerts WHERE id = $day") or die(mysql_error()); $row1 = mysql_fetch_array($result1); } } } $params = array('access_token' => $facebook_access_token, 'message' => $row1[alert_message], 'name'=> $row1[alert_name], 'caption' => $row1[alert_caption], 'link' => $row1[alert_link], 'description' => $row1[alert_description], 'picture' => $row1[alert_picture] ); $url = "https://graph.facebook.com/$facebook_id/feed"; $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_POSTFIELDS => $params, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_VERBOSE => true )); $result = curl_exec($ch); ?> The problem seems to be occurring when the While loop is accessed. I have used 'echo' to follow the variables through the script and it all seems to be working. However if I try and execute the cURL and the While Loop has run then it does not seem to work. I know the cURL part works becuase if the variables cause the first IF statement default to ELSE then it runs fine. Any help would be GREATLY appreciated.
  2. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read='0'' at line 1 Lol I could have told you that haha I know it had something to do with the AND part of the statement
  3. <?php function newmessages() { $query = "SELECT COUNT(id) FROM messages WHERE to_id='$_SESSION[uid]'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $num_rows = $row['COUNT(id)']; echo 'Message Inbox (' . $num_rows .')'; } ?> The above statement works, However when I introduce an AND statement it breaks, even though the column name is correct... I dont know whats going on? <?php function newmessages() { $query = "SELECT COUNT(id) FROM messages WHERE to_id='$_SESSION[uid]' AND read='0'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $num_rows = $row['COUNT(id)']; echo 'Message Inbox (' . $num_rows .')'; } ?>
  4. I have a friends table iduser_idfriend_idactive 1121 2211 3131 I want to delete a friend connection $query = "DELETE FROM friends WHERE user_id='$_SESSION[uid]' AND friend_id='$fid'"; $result = mysql_query($query); How do I delete the connection for the deleted friend too? Sort of like Delete From friends where user_id="This user" AND friend_id ="old_friend" [AND WHERE] user_id="old_friend" AND friend_id="This user"
  5. haha nice to know I could help someone for a change!! =D
  6. add just after the query $num = mysql_num_rows($result); and if there is a result then $num will = 1 or more so then run an if statement if($num >= 1) { echo 'show the profile'; } else { echo 'no results were found'; }
  7. Thanks the is_numeric worked as I had required! I had seen it before but cant remember why I didnt try it? I need to be able to call the function within itself as there is a mysql Select carried out during the content generation... if the $_GET variable is not a valid user profile id then the function defaults to the users own id function viewprofile($user) { if(!empty($user) && is_numeric($user)) { $query = "SELECT users.*, user_profiles.* FROM users, user_profiles WHERE users.id='$user' AND user_profiles.user_id = users.id"; $result = mysql_query($query); $num = mysql_num_rows($result); $row = mysql_fetch_assoc($result); if($num == 1) { echo ' <div id="profile_container"> <div id="profile_left"> <div id="profile_info"> <h2>'.$row['username'].'</h2> <img src=""/> <h3>Communication</h3> <ul> <li><a href="">Message</a></li> <li><a href="">Add Friend</a></li> </ul> </div> <div id="status"> <h3>Status</h3> <ul> <li><p><span>Page Hits:</span>'.$row['views'].'</p></li> <li><p><span>Member Since:</span>'.$row['created'].'</p></li> <li><p><span>Last Active:</span>'.$row['lastlogin'].'</p></li> <li><p><span>Creatures Caught:</span>--</p></li> </ul> </div> <div id="personal_stats"> <h3>Personal Status</h3> <ul> <li><p><span>Makes Me Happy:</span>'.$row['happy'].'</p></li> <li><p><span>Makes Me Sad:</span>'.$row['sad'].'</p></li> <li><p><span>Perfect Partner:</span>'.$row['partner'].'</p></li> <li><p><span>Bad Habits:</span>'.$row['habits'].'</p></li> <li><p><span>Cigarettes</span>'.$row['cigarettes'].'</p></li> <li><p><span>Alcohol:</span>'.$row['alcohol'].'</p></li> <li><p><span>Race:</span>'.$row['race'].'</p></li> <li><p><span>Hair:</span>'.$row['hair'].'</p></li> <li><p><span>Body Type:</span>'.$row['body'].'</p></li> </ul> </div> <div id="favourite_things"> <h3>Favourite Things</h3> <ul> <li><p><span>Food:</span>'.$row['food'].'</p></li> <li><p><span>Music:</span>'.$row['music'].'</p></li> <li><p><span>TV Show:</span>'.$row['tv'].'</p></li> <li><p><span>Author:</span>'.$row['author'].'</p></li> <li><p><span>Movie:</span>'.$row['movie'].'</p></li> <li><p><span>Nightclub:</span>'.$row['club'].'</p></li> <li><p><span>Person:</span>'.$row['person'].'</p></li> <li><p><span>Place:</span>'.$row['place'].'</p></li> </ul> </div> </div> <div id="profile_right"> <div id="identification"> <h3>Identification</h3> <ul> <li><p><span>Name:</span>'.$row['firstname'].' '.$row['surname'].'</p></li> <li><p><span>Gender:</span>'.$row['age'].' years old ('.$row['star'].'), '.$row['gender'].', '.$row['relationship'].'</p></li> <li><p><span>Location:</span>'.$row['city'].', '.$row['country'].'</p></li> <li><p><span>Profile Link:</span><a href="">http://www.capture.me/'.$row['username'].'</a></p></li> </ul> </div> <div id="more_information"> <h3>Blurb</h3> <ul> <li><p><span>About Me:</span>'.$row['about_me'].'</p></li> <li><p><span>Extra:</span>'.$row['extra'].'</p></li> </ul> </div> <div id="my_adventures"> <h3>My Adventures</h3> <ul class="image_list"> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> </ul> </div> <div id="my_friends"> <h3>My Friends</h3> <ul class="image_list"> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> <li><img src=""/><p>Name</p></li> </ul> </div> </div> </div>'; } else { viewprofile($_SESSION['uid']); } } else { viewprofile($_SESSION['uid']); } } viewprofile($_GET['uid']); Im totally new to PHP and this is the first attempt I have made at writing a function so I know its probably not correct (but it works ) haha PS - Does anyone have any tips on how to include the html code in my function, it just looks soo messy
  8. I have created a function to generate some content using a parameter which is defined using the $_GET method. The function checks to see if the $_GET variable is an integer before generating the content. If it is not I want to run the function again with a definite integer value. However I keep getting an internal server error. function generatecontent($var) { if(is_int($var)) { echo 'content generated'; } else { generatecontent(1); } } generatecontent($_GET['id]); Any Idea where im going wrong :S
  9. I am creating an online game which requires people to log on from as many different ip addresses as they can. In large networks such as the ones in colleges and universities it would be handy if I could record the ip address of the individual computer rather than the one ip address for the router that every computer is connected to. I will look into the javascript method and see if that will be of any use. Thanks
  10. Is it possible to use PHP to detect the IP of a particular computer behind a router? Just now im using $_SERVER['REMOTE_ADDR'] But it seems to only detect the routers IP address
  11. If I assigned people to a group randomly it reduces the chance of having an unbalanced spread of users between the groups. If I have the groups pre determined then areas with a high number of ip addresses in use for the one range will begin to fill up and that information will be more readily avaliable to users. However, if users in an area with an ip range that has minimal traffic then the information will become harder to view...
  12. Im really confused myself with this too lol... When a user logs onto my website I want to record their ip address. I then want that ip address to be checked against the 1000 groups of ip address I have defined to see what one it is in. Each of those 1000 groups will be associated with a page of information. If a user logs on with an ip address of 14.16.18.20 and it is a member of group number 30 then they are able to view information specific to people signing on from that ip range. What I need to know is what are the ranges e.g. (0.0.0.0 - 0.100.0.0) that I would need to define in order to split all the public ip addresses in use just now into 1000 fairly equal groups Any clearer? :S
  13. If you were to take all of the public ip addresses in the world is there a numerical way that you could split them into 1000 groups? I know you can sort them by country or whatever but thats too specific for what I want to try. I want a fairly random spread. I want people to click onto my site and depending on their ip address group be reditected to one of 1000 pages. The country they are in should be recordable but have just as equal a chance of selecting each of the 1000 pages. Thanks for any help
  14. try global $connection; $query = "SELECT * FROM subjects WHERE id='$subject_id' LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); if($subject = mysql_fetch_array($result_set)) { return $subject; } else { return NULL; } }
  15. did you set the id value to auto incriment in the database and update the values for each record?
  16. Replace $db = mysql_connect ($host, $username, $password) or die ('I cannot connect to the database because: ' . mysql_error()); with mysql_connect ( $host, $username, $password)or die("Could not connect: ".mysql_error());
  17. I came here one day to find a solution to a problem I couldn’t solve by using Google and the likes. I just didn’t realise how many different problems I might come across when writing the code for my site!! I thought about giving up or maybe even settling for a pre programmed php script but I didn’t. So get ready for a torrent of different questions haha Hey everyone
  18. Yes, set it as the primary field and set it to auto incriment. Almost every table should have one as it is a good way to destinguish between rows.
  19. $sql = "UPDATE aiimjoin SET company ='What you want company set to' WHERE uid ='$_SESSION[uid]'"; You said in your code $result = mysql_query($sql) or die ( mysql_error() ); The mysql_query($sql) part is looking for a $sql variable with a mysql query. You have set the query, but it is not assigned to a variable.
  20. <?php echo $_SERVER['PHP_SELF']."?id=".$row['id'];?> ? Then use $_POST['id'] to select the id on submit
  21. Woops sorry $array = "1,2,3,4,5"; $get_booking_query = "SELECT * FROM booking_form as b LEFT OUTER JOIN issues as m ON FIND_IN_SET(m.issue_number , b.bf_issues_booked ) > 0 WHERE m.issue_number IN ($array)";
  22. WHERE m.issue_number IN $array? I did this in one of my news scripts but I dont know if it is correct. $array was just a comma sepperated list $array = 1,2,3,4,5;
  23. $year = $_POST['year']; $month = $_POST['month']; $day = $_POST['day']; if ($year != 'none' || $month != 'none' || $day != 'none') { if ($year == 'none' || $month == 'none' || $day == 'none') { $errors[] = 'The birthdate you provided was not complete.'; } else { $dob = "$year"."$month"."$day"; } } if (empty($errors)) { $query = "INSERT INTO users (dob) VALUES('$dob')"; mysql_query($query) or die(mysql_error()); mysql_close(); } else { echo "$errors"; exit(); }
×
×
  • 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.