Jump to content

Barand

Moderators
  • Posts

    24,565
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. You are setting $to to the string value 'email' and not to the posted email value in $email.
  2. So output the others as you did with the product name, putting the <br> after the details output. The image will require an <img src="imagename" /> tag
  3. SELECT a.id , a.name as item , b.name as parent FROM cat AS a LEFT JOIN cat AS b ON b.parent = a.id
  4. I don't know what the table is called. It's your table. I am just showing how to subtract the current time from another and get the result SELECT TIMEDIFF(expire, NOW()) as time_remain FROM whateveryourtableiscalled
  5. Use TIMEDIFF() function EG mysql> SELECT TIMEDIFF('2015-02-07 18:00:00', NOW()) as time_remain; +-------------+ | time_remain | +-------------+ | 02:53:29 | +-------------+
  6. your sql syntax is screwed up. The select query should look like SELECT id, ip FROM banned WHERE ip='$user_ip'
  7. You'll have to do it the long way. Examine every query, and the output from those queries, and see what columns are referenced from each table. Just hope the author was sensible enough not to use "SELECT * " in the queries. Good luck.
  8. If $serial is unique, use that as the value. I used ID as a generic meaning the unique identifier for each row as i do not know what your table looks like
  9. What happens if you move the IFNULL() from the COUNT() to AVG(drops) SELECT IFNULL(AVG(drops), 0) .... Do you need the course and course_section tables in that query? They look redundant.
  10. You are passing the string "filename" instead of the variable filename
  11. Add another <td>..</td> containing a checkbox. Give each checkbox a value which is the primary key of the row (a unique id). EG <td><input class="cb" type='checkbox' name='status[]' value='123'></td> Use JS to submit an AJAX request on click of the checkbox which will then run a php script containing UPDATE wip_master SET status=10 WHERE id = $id and then set the row colour to red.
  12. The comma after :requestby should be an "AND". That's why it's telling you there is a syntax error there - read the message.
  13. That line should be OK, the filename is being sentin $_POST['filename']. You could test it by putting exit ($filename); directly after that line. The filename should appear in the alert() box.
  14. You can do it with GD but I would recommend using SVG so you can scale it as you like with losing resolution.
  15. What aspect are you stuck on?
  16. $POST should be $.post (call jquery $.post function) "Hva skjer her?" should be "text" (tell the function the response is plain text)
  17. Impossible to tell from that code what is commented out and what isn't. But as another old guy with a bit of PHP/SQL experience I would store the files in the file system (that's why they call it that) and store the reference to the file in the database.
  18. I use this method $where = array(); $whereclause = ''; if ($subject != '') { $where[] = "SUBJECT = :subject"; } if ($topic != '') { $where[] = "TOPIC = :topic"; } if ($title != '') { $where[] = "TITLE = :title"; } if (count($where) > 0) { $whereclause = " WHERE " . join(' AND ', $where); } $sql = "SELECT * FROM periodic" . $whereclause;
  19. "\r\n" is 2 characters (CR LF) '\r\n' is 4 characters (note the single quotes) If you can see \r\n in the string then it's not a CRLF pair and nl2br() won't work, so try your str_replace with single quotes instead of double
  20. stripos() is case insensitive. $blacklist = file('blacklist.txt', FILE_SKIP_EMPTY_LINES); $whitelist = file('whitelist.txt', FILE_SKIP_EMPTY_LINES); $srch = 'phpFreaks'; if (array_filter($whitelist, function($var) use ($srch) {return stripos($var,$srch)!==false;})) echo "Allowed"; elseif (array_filter($blacklist, function($var) use ($srch) {return stripos($var,$srch)!==false;})) echo "Not allowed"; else echo "Unknown site";
  21. You ARE using joins. If you SELECT ... FROM A,B,C without any join conditions you create a cartesian join which joins every record in each table with every record in every other table. So if A, B and C each contain 1000 rows then you return 1000 x 1000 x 1000 rows ie 1 billion. So now you know where the memory is going
  22. Following on from Cronix's reply (#41) Easiest way to do an AJAX call is with jquery <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"> function playVideo(url, filename) { // AJAX call to post filename to your update script $.post( "my_update.php", {"filename":filename}, function(data) { // do whatever with whatever you send back in "data" // eg if you send back an error message if (data != '') { alert(data); } else { // show video window.open(url); return false; } }, "text" ); } </script> Whatever you echo in the update script will be sent back as the response in the "data" variable above.
  23. It doesn't throw the fatal error but it does still give a no index used. mysqli_report(MYSQLI_REPORT_ALL); try { $res = $db->query("SELECT id, name FROM tablea ORDER BY id"); if ($res) { while (list($i, $n) = $res->fetch_row()) { echo "$i, $n<br>"; } } } catch (Exception $e) { echo "Error: " . $e->getMessage(); } //RESULT Error: No index used in query/prepared statement SELECT id, name FROM tablea ORDER BY id
  24. And what has staff_type got to do with which member of staff they want to see? It's the staff_id that will identify a staff member. Your programming style like someone playing "Pin the tail on the donkey" - copy a line of code, close your eyes, paste it and hope for the best.
  25. I'm convinced the "no index used" error is a mysql bug. CREATE TABLE `tablea` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) DEFAULT NULL, `position` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 then mysqli_report(MYSQLI_REPORT_ALL); $db->query("SELECT id, name FROM tablea"); gives
×
×
  • 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.