Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. you could have it split the search terms up so its "WHERE title LIKE '%i%' AND title LIKE '%gotta%' AND title LIKE '%feeling%' AND title LIKE '%black%' AND title LIKE '%eyed%' AND title LIKE '%pees%'"... i'm assuming there'd be an easier way tho i.e. $search = "i gotta feeling black eyed pees"; $search = ltrim(rtrim($search)); //get rid of whitespace at start n end $search = explode(" ", $search); $sqlSearch = array(); foreach ($search as $s) { $sqlSearch[] = "title LIKE '%$s%'"; } $sqlSearch = implode(" AND ", $sqlSearch); $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query("SELECT * FROM `musiclinks` WHERE $sqlSearch $max") or die(mysql_error()); if ($data_p){ //This is where you display your query results while ($postede = mysql_fetch_assoc($data_p)) { $name = "{$postede['title']}"; $genre = "{$postede['genre']}"; $filename = "{$postede['filename']}"; $embed = "{$postede['embed']}"; $false = 'False'; $true = 'True'; }
  2. is $sr a $_POST variable..? with a term like "the beatles"? you can do something like $sr = explode(" ", $sr); $sr = implode("%", $sr); or $sr = str_replace(" ", "%", $sr); would do the same... then you will get $sr = 'the%beatles' is that what you were after?
  3. try this and see how it goes for time... you don't have any triggers etc set up in your mysql database? function getmicrotime(){ list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } $time_start = getmicrotime(); mysql_query("INSERT INTO forum_replies(tid,uid,message,date,time) VALUES('1','2','3','4','5')"); $time_end = getmicrotime(); $time = $time_end - $time_start; echo "Query took $time seconds";
  4. is $user->uid calling a function or a variable... if its a variable check its public? otherwise if its a function check its returning the correct result... i'm assuming the "user" object is created before you define the constant (USER_ID)..?
  5. woops, misread your question. will reply soon
  6. you could try seeing how long the query takes.. i.e. function getmicrotime(){ list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } $time_start = getmicrotime(); mysql_query("INSERT INTO forum_replies(tid,uid,message,date,time) VALUES('$tid','".$_SESSION['user_id']."','$msg','$date','$time')"); $time_end = getmicrotime(); $time = $time_end - $time_start; echo "Query took $time seconds";
  7. $file_handle = fopen("yourtextdoc.txt", "rb"); $textArray = array(); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $textArray[] = $line_of_text; } fclose($file_handle); //now your lines of text are stored in $textArray
  8. haha sorry! i wrote that foreach loop as if it were in C#, // ##### Complete Job and Insert into DB ##### Start -> if ($_POST[submit] == "Complete") { $jobs = $_POST['checkbox']; $jobIDs = array(); foreach ($jobs as $job) { $jobIDs[] = "('$job')"; } //implode with "," for sql $jobIDS = implode(", ", $jobIDs); $sql = "INSERT INTO tbl_jobs_done(jobs_id) VALUES $jobIDS;"; $result = mysql_query($sql); } // ##### Complete Job and Insert into DB ##### End <-
  9. for the insert have $jobs = $_POST['checkbox']; $jobIDs = array(); foreach ($job in $jobs) { $jobIDs[] = "('$job')"; } //implode with "," for sql $jobIDS = implode(", ", $jobIDs); $sql = "INSERT INTO tbl_jobs_done(jobs_id) VALUES $jobIDS;";
  10. <?php if(isset($_POST[search])) { $title = strtolower(strip_tags(mysql_escape_string($_POST['title']))); $name = strtolower(strip_tags(mysql_escape_string($_POST['name']))); $occupation = strip_tags(mysql_escape_string($_POST['occupation'])); $termsArray = array(); if(!empty($title)) { $termsArray[] = "f.title LIKE '%$title%'"; } if(!empty($name)) { $termsArray[] = "p.name LIKE '%$name%'"; } if (count($termsArray) > 0){ $terms = implode(" AND ", $termsArray); $terms = " WHERE ".$terms; unset($termsArray); } $join = (empty($title) && empty($name)) ? "WHERE" : "AND"; $sql_occupation = ($occupation == all) ? "" : "$join occupation='$occupation'"; if ($sql_occupation != ""){ $join = "AND"; } $qSearch = "SELECT DISTINCT f.*, 'film' AS table1, p.*, 'people', r.* FROM related r LEFT JOIN film f ON r.title = f.title LEFT JOIN people p ON r.name = p.name $terms $sql_occupation "; $rsSearch = mysql_query($qSearch) or die(mysql_error()); if (mysql_num_rows($rsSearch) == 0) { print '<p>Sorry, there were no results returned for your search. Please try again.</p>'; } else { print '<center><p><strong>'.mysql_num_rows($rsSearch).'</strong> related item(s) found.</p></center>'; $film = ''; $people = ''; $relationships = ''; $lastTitle = ''; $lastPerson = ''; while ($row = mysql_fetch_array($rsSearch)) { extract($row); //check if last name equals current name, if so if ($name != $lastPerson) { $people .= '<div class="boxgrid captionfull"> <a href="biography.php?name='.$title.'"><img src="images/thumbnails/'.$image.'.jpg"></a> <div class="cover boxcaption"> <a href="biography.php?name='.$title.'">'.$title.' ('.$occupation.')</a> </div> </div>'; $lastPerson = $name; } //check if the last film in loop is the same, if so add names to the end, otherwise start new line and add to film variable $title = $row['title']; if ($title == $lastTitle) { $relationships .= ' | ' . $name; } else { $relationships .= "<br />$title | {$name}"; $lastTitle = $title; $film .= '<div class="boxgrid captionfull"> <a href="filmography.php?title='.$title.'"><img src="images/thumbnails/'.$image.'.jpg"></a> <div class="cover boxcaption"> <a href="filmography.php?title='.$title.'">'.$title.' ('.$year.')</a> </div> </div>'; } } } echo "FILM<br />$film<br/>PEOPLE<br/>$people<br/>RELATIONSHIPS<br/>$relations"; } ?>
  11. not exactly sure what you wanted it for, but you can encrypt/decrypt AES/DES encryptions with mysql... http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html
  12. for the related items have something like $lastTitle = ''; while ($r = mysql_fetch_array($rsSearch)) { $title = $r['title']; if ($title == $lastTitle) { echo ' | ' . $r['name']; } else { echo "$title | {$r['name']}"; $lastTitle = $title; } }
  13. you've got a many to many relationship between actors and films so you need a association table. i.e. People pid <-- people id Name Occupation Film fid <-- film id Title Year Related fid pid then for each relationship insert the corresponding ID numbers into the related table. then use joins and you'll be able to do all your searches without the union all..... also, at the moment you're referring to database entries by "name" and "title", both of which are not necessarily unique identifiers for each row, for your links, use unique ids... like <a href="biography.php?pid='.$id.'">
  14. you've got your PHP all jumbled up.. you're calling to fetch the page from the server after you try to read it... <?php if(isset($_POST['lookup'])) { $itemnumber = $_GET['itemnumber']; $content = file_get_contents('http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=' . $itemnumber); $lookup = $_POST['lookup']; $minimum = explode('<b>Minimum price:</b> ',$content); $minimum2 = explode('</span>',$minimum[1]); $minimumprice = $minimum2[0]; $current = explode('<b>Market price:</b> ',$content); $current2 = explode('</span>',$current[1]); $currentprice = $current2[0]; $maximum = explode('<b>Maximum price:</b> ',$content); $maximum2 = explode('</span>',$maximum[1]); $maximumprice = $maximum2[0]; } ?> <form action="" method="POST"> <input type="text" name="itemnumber" /> <input type="submit" value="Lookup" name="lookup" /> </form> <?php if(isset($_POST['lookup'])) { echo 'Minimum Price: ' . $minimumprice; echo '<br>'; echo 'Market Price: ' . $currentprice; echo '<br>'; echo 'Maximum Price: ' . $maximumprice; unset($content,$minimum,$minimum2,$current,$current2,$maximum,$maximum2); } ?>
  15. hmm there doesn't seem to be a dedicated page for it, but http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add has a bit
  16. to join film and people, use a "JOIN". your related table should have people ID (people_id) and film ID (film_id) rather than title and name. $sql = "SELECT * FROM people JOIN related ON people.id = related.people_id JOIN film ON related.film_id = film.id WHERE whatever"; i don't understand whether you want to search for films? Or search for actors?... shouldn't there be a radio button so they can select? i'd have two seperate MYSQL queries... and then two loops to echo the information, one for people and one for films...?
  17. wat type of field is "last_movement"? datetime? if so you can change that sql to $sel_users_online = mysql_query("SELECT * FROM rscd_members WHERE last_movement > NOW() - INTERVAL 5 MINUTE"); wat error are you getting? its just not selecting any members?
  18. shouldn't the error be something like "unable to connect to 123.493.495.34:43594 (Connection refused)" ... instead of "unable to connect to hey:43594 (Connection refused)"...?
  19. mysql_fetch_array() can be used for single results also... i stuffed up the previous bit of code, mysql_fetch_row() returns an array with number indexes representing the columns, i.e. $result[0], $result[1] etc <?php include_once 'Connect.php'; if (!is_authed()) { die ('You are not permitted to view this page, <a href="index.php">click here</a> to go back.'); } $thequery = ("SELECT * FROM members WHERE id = '". $_SESSION['id'] ."'"); //this query i want it to get data from database where it = session data // then i plan to display it on page $query = mysql_query($thequery) or die ('id and session data dont match.'); $result = mysql_fetch_array($query); ?> <html><head></head><body> age<br><?php echo $result['age']; ?> </body></html> or you could use mysql_fetch_row() and have <?php echo $result[0]; ?>... i'd go with the first option tho
  20. are you familiar with any computer programming languages? it would be pretty easy to write a script which when the IP changes it loads a page on the server which takes the ip address.. visual studio has built in browser windows etc for its forms, so you could have a tiny application with a built in browser and each time the IP address changes (check say every 60seconds?) then it will tell the browser to go to that page... and it can have a built in authorisation code incase bots etc access it and the ip gets changed i.e. www.yourserver.com/php/updateIP.php?authCode=a4jsdncx8234jklsdj2343k52nKLJSDFAH3b if (isset($_GET['authCode']) == 'a4jsdncx8234jklsdj2343k52nKLJSDFAH3b') { $ip = $_SERVER['REMOTE_ADDR']; $sql = @mysql_query("UPDATE ipAddress SET ip = '$ip'"); }
  21. when you pull data from a mysql table it puts it into an array with the column names as indexes... you also need to fetch the data with mysql_fetch_row() or mysql_fetch_array() etc i'm assuming $age is referring to a column in your database called "age"? <?php include_once 'Connect.php'; if (!is_authed()) { die ('You are not permitted to view this page, <a href="index.php">click here</a> to go back.'); } $thequery = ("SELECT * FROM members WHERE id = '". $_SESSION['id'] ."'"); //this query i want it to get data from database where it = session data // then i plan to display it on page $query = mysql_query($thequery) or die ('id and session data dont match.'); $result = mysql_fetch_row($query); ?> <html><head></head><body> age<br><?php echo $result['age']; ?> </body></html> that works if the mysql query you sent only returns one row.. which it will in this case however, if you have a mysql query which returns several rows i.e. "SELECT * FROM members"; you need to use mysql_fetch_array() and put it in a while loop like so $sql = @mysql_query("SELECT * FROM members"); while ($row = mysql_fetch_array($sql)) { echo $row['age']; }
  22. $_SERVER['REMOTE_ADDR']; gets the clients IP address from the interaction between the server and the client. i.e. if you had a page <?php echo $_SERVER['REMOTE_ADDR']; ?> it would echo the IP of the person viewing the page.
  23. <table> <?php $rowcount = 0; while ($row = mysql_fetch_array($sql)) { if ($rowcount % 4 == 0) { echo '<tr>'; } ?> <td> <?php echo $row['record']; ?><br> </td> <?php if ($rowcount % 4 == 0) { echo '</tr>'; } $rowcount++; } ?> </table>
  24. first up, you should have error_reporting set to E_ALL for this if your debugging, not error_reporting(0); second you have the timeout set to 2seconds, up it to 15 for testing. and third try echoing $server and $port to ensure the correct values are getting passed.
×
×
  • 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.