Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Indeed, and that's why I said "the odds of not running your browser maximized increases with the resolution of the monitor". Just because resolutions tends to grow bigger and bigger it doesn't mean the viewport does as well. At a certain point it becomes infeasible having maximized windows for reading text. See this monitor for instance.
  2. Well, that sort of depends on what you want to do, and considering you're the only one who knows that, you're the only one who can answer that question...
  3. That presupposes a maximized browser window. The odds of not running your browser maximized increases with the resolution of the monitor. Monitor resolution != viewport size.
  4. Search the forums. Believe it or not, but you're not the only person who ever got the idea of implementing a login system.
  5. Okay, so we'll call him an ogre then.
  6. $time = mktime(0, 0, 0, $month, 1, $year); $numDays = date('t', $time); foreach (range(1, $numDays) as $day) { echo $day; } Or if you want a one-liner: echo join(', ', range(1, date('t', mktime(0, 0, 0, $month, 1, $year))));
  7. See: session_set_cookie_params in the manual, and "Sessions and cookies: Adding state to a stateless protocol" on this site. They default to last until the UA is closed. Only if you restart your browser every 20 minutes are you correct
  8. If you wish to stay here you'll have to improve your behavior and start showing some respect to the people you demand should give you free help. Hell, even the username you picked is disrespectful.
  9. Well, obviously you should remove the error suppression and perhaps try to check the values of $errorNumber and $errorMessage variables you are defining. How about trying to help yourself? I believe numerous people already told you so. Did you read that document about how to ask questions I referred you to? If you haven't, do that and don't post here before you've read it completely.
  10. Have you saved your files as UTF-8 as well? Functions such as htmlentities also take a charset argument.
  11. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
  12. Daniel0

    HP & Dell

    If it's unsupported then it's unsupported. I know you can purchase casings for "normal" internal HDDs so they can be used like an external HDD via USB. Maybe something similar exists for laptop HDDs. Edit: Somehow I thought "laptop" when I read your post. I obviously don't know if that's the case, but you can buy those casings.
  13. Well, I would say it's an obvious truth. If I have the choice between helping you and getting paid, or helping someone else and not getting paid, who do you think I will help? I believe most of the people who feel they're competent enough to help people share the same point of view. You can see it as freelance consulting if you wish. Priority support costs and if you're not willing to pay then you'll have to wait in the line and hope someone finds your problem interesting enough that they want to help you for free.
  14. Well, having only 14 posts I count 3 violations of the rules already: http://www.phpfreaks.com/forums/index.php/topic,255353.msg1200777.html#msg1200777 http://www.phpfreaks.com/forums/index.php/topic,245245.msg1146039.html#msg1146039 http://www.phpfreaks.com/forums/index.php/topic,255368.msg1200870.html#msg1200870 21% of your posts violated the rules. Maybe the problem isn't the speed, but your way of posting. Read this. Yes, read it all. Yeah, it's pretty long, but read all of it anyway. And not just read it, but follow it. Anyway, if you want faster help then send me some money and I'll prioritize your posts higher than the other ones.
  15. It's called checked instead.
  16. Yeah call_user_func_array(array($object, 'function'), array('arg1', 'arg2'));
  17. By your own given possible answers, you're the idiot mysql_fetch_*() moves the pointer one forward. Eventually the pointer will be at the end in which case those functions will return FALSE.
  18. If you've encrypted something then you can decrypt it. An encryption function is by definition injective.
  19. <option value ="Devlopers"<?php if ($value == 'Devlopers'): ?> selected="selected"<?php endif ?>>Devlopers</option>
  20. For each option, check if the value corresponds to the previously selected value. If it does, mark it as selected.
  21. Sessions give you control over how to store the data. The only thing the user will then be responsible for storing is their own session identifier.
  22. call_user_func_array
  23. Well, try this: <?php $user="xxxx"; $password="xxxx"; $host="xxxx"; $database="xxxx"; $table="test"; $allfieldsfull=true; $errormessage='Please fill in all the fields!'; $order=true; $thank_you_text='Thank you! Your answers have been saved.'; if (!count($_POST)) { echo "There is no form input to be processed."; exit; } $identification = $_POST['identification']; $counter = $_POST['counter']; if (empty($identification)) { $referer = rtrim($_SERVER['HTTP_REFERER'],"/ \t\n\r\0\x0B."); } if ($allfieldsfull) { foreach($variablen as $name => $value) { if (empty($value)) { echo $errormessage; echo '<br><br><a href="javascript:history.back()"><---</a>'; exit; } } } if ($order) { ksort($_POST); } $next_page = $_POST['next_page']; $counter_page = ++$counter+1; mysql_connect($host,$user,$password) or trigger_error("Unable to connect to database server: " . mysql_error(), E_USER_ERROR); if (!empty($identification)) { mysql_query("CREATE DATABASE $database"); } mysql_select_db($database) or trigger_error("Unable to select database: " . mysql_error(), E_USER_ERROR); if (!isset($identification)) { mysql_query("CREATE TABLE $table (`identification` int(9) NOT NULL auto_increment, `page1` TEXT, `participation_date` DATE, `time_submit1` VARCHAR(, `ip_number` VARCHAR(15), `browser` TINYTEXT, PRIMARY KEY (`identification`)) TYPE=MyISAM") or trigger_error("Error: " . mysql_error(), E_USER_ERROR); } //change array, so that time_submit and page are renamed dynamically foreach($_POST as $name => $value) { if ($name == "next_page") { $name = "page" . $counter_page; } else if ($name == "counter") { $name = "time_submit" . $counter; $value = date("G:i:s"); } $newarray[$name] = $value; } $variables = $newarray; //for each line in the array of submitted variables do the following (traverse array) foreach($variables as $name => $value) { //modify table step by step (add colums according to html input) mysql_query("ALTER TABLE $table ADD `" . mysql_real_escape_string($name) ."` VARCHAR(15)"); } if (empty($identification)) { //insert new record into db table (into the referer field) and thus generate identifcation (new record) $referer = mysql_real_escape_string($referer); $ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $useragent = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']); $date = date('Y-m-d'); $time = date('G:i:s'); $query = "INSERT INTO {$table} (page1, participation_date, time_submit1, ip_number, browser) VALUES ('{$referer}', '{$date}', '{$time}', '{$ip}', '{$useragent}')"; mysql_query($query) or trigger_error("Unable to insert into table: " . mysql_error(), E_USER_ERROR); //grab last value of auto-increment variable "identification" to be used as identifier $identification = mysql_insert_id(); } $identification = mysql_real_escape_string($identification); //for each line in the array of submitted variables do the following foreach($variables as $name=>$value) { //echo $name." - ".$value."<br>"; //spits out array for control purposes //update db table step by step $name = mysql_real_escape_string($name); $value = mysql_real_escape_string($value); mysql_query("UPDATE $table SET `{$name}`='{$value}' WHERE identification='{$identification}'") or trigger_error("Error: " . mysql_error(), E_USER_ERROR); } //close connection mysql_close(); if (!isset($next_page)) { echo $thank_you_text; } else { //call up next HTML page and pass on ID and counter echo "<html><head></head><body onLoad=\"javascript:location.replace('".$next_page."?op56=".$identification."&nr93=".$counter."')\"> <a href=\"".$next_page."?op56=".$identification."&nr93=".$counter."\">Next Page</a></body></html>"; } ?> Really though, I don't think your colleague knows what (s)he is doing. I don't hope his/her job is programming. Tell that person to look up these things: Database normalization, input sanitation, error handling, separation of concerns, formatting and indent styling (the code was nearly unreadable due to poor formatting).
  24. Well, it's still a bad idea. Tables aren't meant to be created on the fly like that. You could have a database schema like this: CREATE TABLE `surveys` ( `survey_id` int(10) unsigned NOT NULL auto_increment, `title` varchar(100) NOT NULL, `description` text, PRIMARY KEY (`survey_id`) ) ENGINE=InnoDB; CREATE TABLE `questions` ( `question_id` int(10) unsigned NOT NULL auto_increment, `survey_id` int(10) unsigned NOT NULL, `question` varchar(100) NOT NULL, PRIMARY KEY (`question_id`), CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`survey_id`) REFERENCES `surveys` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; CREATE TABLE `users` ( `user_id` int(10) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB; CREATE TABLE `responses` ( `response_id` int(10) unsigned NOT NULL auto_increment, `question_id` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, `response` text NOT NULL, PRIMARY KEY (`response_id`), CONSTRAINT `responses_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `responses_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `questions` (`question_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; And then here is some sample data: INSERT INTO `surveys` (`survey_id`, `title`, `description`) VALUES (1, 'Quick test survey', 'Just a quick test to illustrate usage.'); INSERT INTO `questions` (`question_id`, `survey_id`, `question`) VALUES (1, 1, 'Where do you live?'), (2, 1, 'How is the weather outside?'); INSERT INTO `users` (`user_id`, `name`) VALUES (1, 'Daniel'), (2, 'John Doe'); INSERT INTO `responses` (`response_id`, `question_id`, `user_id`, `response`) VALUES (1, 1, 1, 'Denmark'), (2, 2, 1, 'It''s okay right now.'), (3, 1, 2, 'USA'), (4, 2, 2, 'It''s raining.'); And getting data could be like this: SELECT u.name, q.question, r.response FROM surveys AS s INNER JOIN questions AS q ON s.survey_id = q.survey_id INNER JOIN responses AS r ON q.question_id = r.question_id INNER JOIN users AS u ON r.user_id = u.user_id WHERE s.survey_id = 1 ORDER BY u.user_id, q.question_id; Which would result in something like this: +----------+-----------------------------+----------------------+ | name | question | response | +----------+-----------------------------+----------------------+ | Daniel | Where do you live? | Denmark | | Daniel | How is the weather outside? | It's okay right now. | | John Doe | Where do you live? | USA | | John Doe | How is the weather outside? | It's raining. | +----------+-----------------------------+----------------------+ This is better and is normalized. You won't have any anomalies in the data, you have constraints to ensure data integrity, it scales better and will be much more efficient.
  25. Well, that's just not the way tables are meant to be used. Imagine you got a million responses. That would mean a million different tables with only one row in each. Surely you can see the problem with that. Also check how how many queries you are executing to insert ONE row. It doesn't scale at all, it isn't normalized and it will be a rather complex task retrieving all the responses.
×
×
  • 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.