Jump to content

jazzman1

Staff Alumni
  • Posts

    2,713
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by jazzman1

  1. Hi cripin, sorry for that, just ignore it. I was very surprised when I saw that "COUNT" is NOT a reserved world in mysql. https://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
  2. There are lots of errors in those queries. Take a look at php.net how to the mysqli_error() function.
  3. What did you expect from us to read all bunch of code? Turn on error_reporting and tell us what part of the script you don't understand.
  4. You have to discribe or rename new changes also inside the conf file of the web server making it as a web root! EDIT: Don't forget to restart the web server after new changes
  5. Because every time you used to change the rules
  6. You don't have to prefix the URL by http://. Here is it: // get host name from URL $host = "www.12.er-3x.5g-3v.mysite.com"; // or 12.er-3x.5g-3v.mysite.com //or http://www.12.er-3x.5g-3v.mysite.com preg_match('/^((\bhttps?:\/\/(www.)?|\bwww\.)?([a-z.-\d]+)?\.)?([a-z\d]+\.[a-z]{2,4}\/?)$/i', $host, $matches); echo '<pre>'.print_r($matches, true).'</pre>'; Also, when a new user try to make a registration, make sure (validate) what characters are acceptable to create this sub-domain.
  7. Hey Tom, you have a lot of things to do if you're planning to administrate that server by php. In mine point of you php is not suited to do this. So, are you able to run as root bash (perl) scripts on this machine or you have only access to the admin control panel?
  8. Hey Tom, I like that forum b/s the people especially gurus (moderators) they provide us lots of useful information. So, going back to my RegEx if you're planning to match any domains and sub-domains containing integers inside their names just set those characters to this particular regex class. For example: <?php // get host name from URL $host = "http://www.mysite1234.mysite.com"; //or http://www.mysite1234.com // or whatever you want preg_match('/^((\bhttps?:\/\/(www.)?|\bwww\.)?([a-z.-\d]+)?\.)?([a-z\d]+\.[a-z]{2,4}\/?)$/i', $host, $matches); echo '<pre>'.print_r($matches, true).'</pre>'; I know that my example is a little complicate to you, but in fact that it's much more powerful and flexible. If you want to learn more about regex, I highly recommend you to start from here. Regards, jazz.
  9. He-he, in fact that my English language translator engine is completely broken, that's why I am here I like you.
  10. You are doing something wrong: // get host name from URL $host = "http://www.liberate.mysite.com/"; preg_match('/^((\bhttps?:\/\/(www.)?|\bwww\.)?([a-z.-]+)?\.)?([a-z]+\.[a-z]{2,4}\/?)$/i', $host, $matches); echo '<pre>'.print_r($matches, true).'</pre>'; Results: Array ( [0] => http://www.liberate.mysite.com/ [1] => http://www.liberate. [2] => http://www. [3] => www. [4] => liberate [5] => mysite.com/ ) But.... it's too late for me I'm going bed.
  11. It's a little late in Canada Give me back the result of: echo $_SERVER["HTTP_HOST"];
  12. Ok, I've created a new one that will get all posible variants to this moment. The sub-domain always will be - $user = $matches[4]; The domain - $user = $matches[5]; You can use $host = $_SERVER["HTTP_HOST"] to get the domain (sub-domain) name for every user. Next URL's will be matched: <?php // http://www.test-net.mysite.com // https://www.test-net.mysite.com/ // www.test-net.mysite.com // test-net.mysite.com // http://mysite.com (only with domain name) // etc...... // get host name from URL $host = "canada.host-name.mysite.com"; preg_match('/^((\bhttps?:\/\/(www.)?|\bwww\.)?([a-z.-]+)?\.)?([a-z]+\.[a-z]{2,4}\/?)$/i', $host, $matches); echo '<pre>'.print_r($matches, true).'</pre>';
  13. What is the of $_SERVER["HTTP_HOST"]? To work this RegEx the value must begin with : "http://", "https//", "http://www" or "www".
  14. Ops.....my typo sorry for that: <?php // get host name from URL $host = "http://www.any-user.name.mysite.com"; preg_match('/((\bhttps?:\/\/(www.)?|\bwww\.)([a-z.-]+)?\.([a-z]+\.[a-z]{2,4}(\/)?)$)/i', $host, $matches); echo '<pre>'.print_r($matches, true).'</pre>'; Results: Array ( [0] => http://www.any-user.name.mysite.com [1] => http://www.any-user.name.mysite.com [2] => http://www. [3] => www. [4] => any-user.name [5] => mysite.com )
  15. @libarate, don't underestimate the power of RegEx.... If you want to match links that contains a "-" symbol just add it between the square brackets, containing sub-domain expression. Example: // get host name from URL $host = "http://www.any.user-name.mysite.com"; preg_match('/((\bhttps?:\/\/(www.)?|\bwww\.)([a-z.-]+)?\.?([a-z]+\.[a-z]{2,4}(\/)?)$)/i', $host, $matches); echo '<pre>'.print_r($matches, true).'</pre>'; Results: Array ( [0] => http://www.any.user-name.mysite.com [1] => http://www.any.user-name.mysite.com [2] => http://www. [3] => www. [4] => any.user-name.mysit [5] => e.com )
  16. @requinix, with respect to you but that example is a pretty static for me, that's why I like RegEX.
  17. So, few things: If you want to match the URL only as domain name for example - $host = "http://mysite.com/", this regEx won't work b/s we need to make a period optional before the domain name. Take that: preg_match('/((\bhttps?:\/\/(www.)?|\bwww\.)([a-z.]+)?\.?([a-z]+\.[a-z]{2,4}(\/)?)$)/i', $host, $matches);
  18. Take a look at this regular expression which I've builded for you. Next URL's will be matched: <?php // https://www.john.doe.mysite.com // https://www.john.doe.mysite.com/ // http://www.john.doe.mysite.com // http://www.john.doe.mysite.com/ // https://john.doe.mysite.com // https://john.doe.mysite.com/ // http://john.doe.mysite.com // http://john.doe.mysite.com/ // www.john.doe.mysite.com // www.john.doe.mysite.com/ // OR their variants // http://www.test.doe.my.siteName.mysite.com/ // get host name from URL $host = "http://test.doe.mysite.com/"; preg_match('/((\bhttps?:\/\/(www.)?|\bwww\.)([a-z.]+)?\.([a-z]+\.[a-z]{2,4}(\/)?)$)/i', $host, $matches); echo '<pre>'.print_r($matches, true).'</pre>'; If you want to get only the prefix, domain, sub-domain, etc....just call the array, something like: echo "My domain name is: ".$matches[5]; echo "My sub-domain name is: ".$matches[6]; Hope, this will help you. jazz..
  19. The php include_path should be located to your php library directory something like - .:/usr/local/php5/lib/php, .:/usr/share/pear:/usr/share/php So, that one (/var/sites/t/testing.indigoonline.co.uk/public_html/php) should be a part of the Apache (web server) confing file! EDIT: Can you run into a linux terminal next command: php -i | grep include_path
  20. So, I've made a test with a real data similar to @OP I guess The table soap: mysql> SHOW COLUMNS FROM soal; +---------------+----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+----------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | Question | varchar(45) | NO | | NULL | | | Answer1 | varchar(45) | NO | | NULL | | | Answer2 | varchar(45) | NO | | NULL | | | Answer3 | varchar(45) | NO | | NULL | | | Answer4 | varchar(45) | NO | | NULL | | | CorrectAnswer | varchar(45) | NO | | NULL | | | Picture | varchar(45) | YES | | NULL | | | Difficulty | smallint(5) unsigned | NO | | NULL | | | Topic | varchar(45) | NO | | NULL | | +---------------+----------------------+------+-----+---------+----------------+ mysql> select * from soal; +----+---------------------+----------+----------+----------+----------+---------------+----------+------------+--------------+ | id | Question | Answer1 | Answer2 | Answer3 | Answer4 | CorrectAnswer | Picture | Difficulty | Topic | +----+---------------------+----------+----------+----------+----------+---------------+----------+------------+--------------+ | 1 | what is the apple? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 1 | | 2 | what is the apple? | Answer 1 | Answer | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 1 | | 3 | what is the apple? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 1 | | 4 | what is the cherry? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 2 | | 5 | what is the cherry? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 2 | | 6 | what is the cherry? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 1 | | 7 | what is the orange? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 3 | | 8 | what is the orange? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 3 | | 9 | what is the pear? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 4 | | 10 | what is the pear? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 4 | | 11 | what is the pear? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 1 | | 12 | what is the cherry? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 1 | | 13 | what is the cherry? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | 1 | some topic 1 | +----+---------------------+----------+----------+----------+----------+---------------+----------+------------+--------------+ All my proposals should be work if her data structure is similar to mine. mysql> SELECT id, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer, Picture -> FROM ( -> SELECT *, -> @num := if(@Question = Question, @num + 1, 1) AS q_number, -> @Question := Question AS q_dummy -> FROM soal -> WHERE Difficulty= 1 AND Topic='some topic 1') AS X -> WHERE X.q_number = 1 -> GROUP BY X.Question; +----+---------------------+----------+----------+----------+----------+---------------+----------+ | id | Question | Answer1 | Answer2 | Answer3 | Answer4 | CorrectAnswer | Picture | +----+---------------------+----------+----------+----------+----------+---------------+----------+ | 1 | what is the apple? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | | 6 | what is the cherry? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | | 11 | what is the pear? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | +----+---------------------+----------+----------+----------+----------+---------------+----------+ 3 rows in set (0.00 sec) mysql> SELECT id, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer, Picture -> FROM soal -> WHERE Difficulty= 1 AND Topic='some topic 1' -> GROUP BY Question; +----+---------------------+----------+----------+----------+----------+---------------+----------+ | id | Question | Answer1 | Answer2 | Answer3 | Answer4 | CorrectAnswer | Picture | +----+---------------------+----------+----------+----------+----------+---------------+----------+ | 1 | what is the apple? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | | 6 | what is the cherry? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | | 11 | what is the pear? | Answer 1 | Answer 2 | Answer 3 | Answer 4 | fruit | some pic | +----+---------------------+----------+----------+----------+----------+---------------+----------+ 3 rows in set (0.00 sec) I think, she has to give us a little more information about database and some sample of data too.
  21. Hm.....you are right, she will get the same result as GROUP BY Question, in case into one topic she has multiple different questions: So, that should work, $sqlText = " SELECT SoalID, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer, Picture FROM ( SELECT *, @num := if(@Question = Question, @num + 1, 1) AS q_number, @Question := Question AS q_dummy FROM soal WHERE Difficulty='". $levelStr ."' AND Topic='". $topic ."') AS X WHERE X.q_number = 1 GROUP BY X.Question ";
  22. @mac_gyver, I am aware of what the message is, but in fact that this message could be also appear as a result of SELinux configuration! That's why my first reaction was to ask @OP about that.
  23. Yes, that's correct. What's wrong about my reply?
  24. Try enclosing the column named "call" with backticks, someting like: $sql = "INSERT INTO member (phoneNumber, firstName, lastName, profilePicture, photo, video, text, `call`, activity, latitude, longitude, data, time) "; https://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
  25. CALL is a mysql reserved word.
×
×
  • 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.