ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
SELECT tech.name, COUNT(ticket.id) FROM tech JOIN ticket ON ticket.tech_id = tech.id WHERE ticket.state = 'open' GROUP BY tech.name ORDER BY COUNT(ticket.id) DESC Adjust for your tables and fields and whatnot. -Dan
-
There is no software anywhere that will allow you to view the files on someone else's computer. You can install corporate spyware on all the user's machines, but that gets very expensive. -Dan
-
Are you absolutely sure it's session_start()? have you commented it out? Does the page load properly without it? If session_start doesn't load, then PHP is probably having trouble accessing the session files. Check PHP.ini to find where they're being stored, and see if there's something wrong with that location. -Dan
-
Also, there is only one instance of mysql_fetch_array in that code. It has one argument. The error message is "the argument to mysql-fetch-array is wrong." From that, you can deduce that $result is wrong. Move up from there to find where it's set. That's wrong. Etc etc. Debugging is tedious, not magical. -Dan
-
keep getting error when UPDATE mysql statement plz help.
ManiacDan replied to loshyt's topic in PHP Coding Help
Always print out the entire query. If you had done so, you would see that there are no quotes around your string variables: $sql2 = "UPDATE `tvchaty`.`episodes` SET `showid` = '".$showid."', `epname` = '".$epname."', `season` = '".$season."', `episode` = '".$episode."', `info` = '".$info.'", `airdate` = '".$airdate."', `directwatch` = '".$directwatch.'" WHERE `episodes`.`id` = ".$id." LIMIT 1"; Also, don't call your sql $sql2, give it a meaningful name. -Dan -
You may be surprised to learn that there's no classes in this code snippet. Do you maybe mean functions? What is the content of datacorrection.php?
-
You're going to have to do this in 2 queries. You could theoretically do it in one, but it would be easier to just select count(*) and SUM(published) and, if they match, do a global update statement. -Dan
-
Wait, so you want ALL rows to set published=0 when NO rows are published=1? By virtue of binary logic, the database already does this. If no rows are published=1, and the only two values are 0 and 1, then all the rows are already zero. -Dan
-
Wait...what are you talking about? Explain better, right now you're getting advice on how to delete your table 3 times an hour. -Dan
-
Seconded (thirded?). SQLite is a great little tool and contains all you need for basic web database work. It lacks a lot of the higher-complexity operations, so you may run into a way if you're trying to do complex reporting on it, but otherwise it's a great choice. -Dan
-
Wrap your OR clauses in parens: SELECT * FROM newgems WHERE (cut='10 Hearts & Arrows' OR cut='8 Hearts & Arrows') AND (colour='Lavender' OR colour='Light Champagne' OR colour='White') -Dan
-
UPDATE `yourTable` SET `yourField` = `yourField` + 1 WHERE `someId` = 123; -Dan
-
Don't store the image in mysql, store it on the filesystem and store the PATH in mysql. Any file upload tutorial will work.
-
Make sure your REPLY-TO is set to the same thing as your FROM. -Dan
-
You have a javascript function that shows these divs, right? Have that function hide EVERY DIV, then SHOW the one you want. Every click, all the divs will be hidden, then the proper one will be shown. -Dan
-
preg_match. Explode works too if you combine it with trim(). -Dan
-
Function to determine if date field is correct on form
ManiacDan replied to webguync's topic in PHP Coding Help
This is why we have JavaScript date pickers. Have the user click the date on a calendar, and the JS fills in YYYY-MM-DD for you. Validating user input has to be by hand, usually with explode(). How can you tell if 3/14/11 is valid? If they live in England, it's not valid. -Dan -
Function to determine if date field is correct on form
ManiacDan replied to webguync's topic in PHP Coding Help
Seconded, the MySQL data format is very close to ISO 8601: "YYYY-MM-DD HH:ii:ss.uuuu" Also, ereg is deprecated, use preg_* -Dan -
Preg_match. Warning, you're about to learn regular expressions. It's a short trip from there to insanity. -Dan
-
It's also called a LOOP, not a cycle. Classes should always be defined outside any control structures (preferably in their own files) and simply instantiated any time they're needed. -Dan
-
// page2 echo '<input type="hidden" name="first_page" value="' . serialize($_POST) .'">'; That won't work if the array is very large, and it will be a waste of bandwidth. Simply using the session is the best solution. -Dan
-
3, really. You don't quote your array indexes, you don't wrap your interpolated variables in curly braces, and you use the 'or die' syntax, which is sloppy. Handle errors properly.
-
That's pointing to PERL, not PHP. But your error messages are PHP. I don't know why you're getting that ouput. As for the rest, they are PHP warnings. You need to set a default timezone in PHP.ini or use date_default_timezone_set to set the timezone. This is exactly what the error message says, so I don't know if this sentence is going to help you at all. -Dan
-
There's a number of things at work here. 1) Each of these is already in its own addressable space: $_POST['formID'] is 3154008308 2) If you want to have data persist between pages, use the session. 3) If you want to store a big list of variables in the session, you would want to make them an array. They are already an array, so breaking them into their own variables would be counter productive. -Dan
-
Data protection for children - UK law question
ManiacDan replied to richrock's topic in Miscellaneous
Which is why I advised him to check with a UK lawyer. They are very VERY careful. Facebook has a minimum age of 13, and cordons off anyone under 18 into their own section. I work for a social network, and we do the same thing. 18 year olds simply do not know 17 year olds exist on the site. We collect less data on the minors as well. That will be of great comfort to him when he's in jail. Generally, "my boss told me to and I didn't bother to check if it was illegal or not" isn't a great defense, especially when his computer history will pull up the "hey I wonder if this is legal" forum thread he created. Talk to a lawyer. A lawyer and only a lawyer can advise you if your actions are legal. If you have questions on the legality of your company's practices, take them up with your boss. -Dan