Jump to content

schilly

Members
  • Posts

    870
  • Joined

  • Last visited

    Never

Everything posted by schilly

  1. wow that sticky is awesome. lots to read =)
  2. hope it wasn't answered already in my other index post. if so, sorry =( thanks for the help though.
  3. cool thanks. ill check it out.
  4. well start with this: $results = mysql_query("SELECT count(forum_posts.id) FROM forum_posts, forum_category WHERE forum_post.category_id = forum_category.cat_id AND cat_parent_id = '$cat_parent_id') or die(mysql_error()); $num_posts = mysql_result($results); This forum_post.category_id = forum_category.cat_id joins forum_posts and forum_category. make sure the fields are whatever their common column is. This: cat_parent_id = '$cat_parent_id' is from your query in your first post so i assume forum_category has this field in it so the results will be filtered based on Sorry there was an error in my post. mysql_results is mysql_result.
  5. does anyone have any good reading for mysql optimization? what should the different caches be set to? buffers? max connect? etc. how to identify problems and determine the culprit? thx.
  6. so I'm trying really hard to tune my db and mainly improve the response time of queries which has got me redoing a bunch of indexes. if you have an index on two fields in a table, is it redundant to have another index on just one of those fields? will a query that uses only one of those fields return just as fast with the two field index as it would with the one field one? thx.
  7. can you post your most recent code?
  8. mysql_numrows is not a function unless you created it. any calls to mysql_numrows should be changed to mysql_num_rows(). put this at the top of your file as well and it should give you some useful errors. ini_set ("display_errors", "1"); error_reporting(E_ALL); and change any of your query calls to mysql_query($gquery) or die(mysql_error());
  9. $gnum=mysql_numrows($gresult); should be $gnum=mysql_num_rows($gresult);
  10. well it depends what the category identifier is like in the forum_posts table but i think you want something like this: $num_posts = mysql_results(mysql_query("SELECT count(forum_posts.id) FROM forum_posts, forum_category WHERE forum_post.category_id = forum_category.cat_id AND cat_parent_id = '$cat_parent_id'));
  11. Is this correct? $gquery="SELECT * FROM images WHERE $id=siteid"; or do you mean $gquery="SELECT * FROM images WHERE siteid=$id";
  12. i dont see how getting the contents of a youtube page is going to play the video. you probably want to look at the youtube embed code: <object width="480" height="385"> <param name="movie" value="http://www.youtube.com/v/4RriC_GnIIE&hl=en_US&fs=1&"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/4RriC_GnIIE&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed> </object>
  13. set a variable in the session or pass a get variable to the script you redirect them to then check for it in your script and display the appropriate message.
  14. basically what i had before except it's not a multi dimensional array: foreach($match[0] as $url){ mysql_query("INSERT INTO links (url) VALUES('$url') ") or die(mysql_error()); } assuming all your urls end up in the $match[0] array else you will need nested foreach loops
  15. if you use a header redirect you can't output anything to the browser before hand.
  16. i think your preg pattern is wrong. you just want the url right? not <img src="picture.jpg">?
  17. yes multiple users can log in at the same time. sessions are independent of each other.
  18. yes that's correct. $match is an array. i think you want this: mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("data") or die(mysql_error()); $url = "http://doamin.com"; $data = file_get_contents($url); preg_match_all("/<img[^>]*>/", $data, $match); $list = $match[0]; foreach($match as $url){ mysql_query("INSERT INTO links (url) VALUES('$url') ") or die(mysql_error()); } print_r($list);
  19. each session is assigned to each user. session can be hijacked but that is another story. it sounds like you don't set the session when the user logs in? typically when someone logs in you: -create the session (session_start()) if one hasn't been created already -put some kind of authentication variable in the session to distinguish the user (ie. username) as well as any other info you will make use of during that persons visit to your site (first name, access level, etc) Now if someone accesses a login restricted page we check the session, validate them then either show the page or redirect them someone else.
  20. http://www.tizag.com/mysqlTutorial/mysqlinsert.php
  21. you need an authentication file which is checked every time a user or admin page loads. there is no point in validating a login if there is no access check on your pages. any admin file needs a check in it that looks for a specific admin variable in the session and the same for the user area. so if you're setting an access level in the session when the person logs in, you check this and either display the page or redirect them somewhere. session_start(); //if they are not an admin if($_SESSION['access_level'] != 1){ header('location: user.php'); exit(); } put that in a file and include it in all your admin pages. create something similar for users as well. that's just an example but it really all depends on how you set your session.
  22. weird. put echo $sql; before the mysql_query() call and look at the actual query.
  23. is the field named "lecture_1"?
  24. couple adjustments. need to reset the set clause each time and add an error check on the query. foreach($_POST['data'] as $student){ $sid = $student['student_id']; $set_clause = ""; foreach($student as $key => $value){ if(substr($key,0,strlen($key)-2) == 'lecture' && $value == 'on') $set_clause .= "$key = $value,"; } $set_clause = substr($set_clause, 0, strlen($set_clause)-1); $con = mysql_connect("devweb2009.cis.strath.ac.uk","dwright","*******"); if (!$con){ die ('Could not connect: '. mysql_error()); } mysql_select_db("dwright", $con); $sql = "UPDATE ProgrammingFoundations SET $set_clause WHERE student_id = $sid"; mysql_query($sql) or die(mysql_error() . " - $sql"); } post any error info from mysql.
×
×
  • 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.