ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
It will be more painful to write the PHP than to change all your filed names. -Dan
-
Then don't do it that way, do it requinix's way. See how it works and is easier? -Dan
-
Array_merge is in the PHP manual: $c = array_merge($a, $b); Implode turns an array into a delimited string, no reason to write your own function here. -Dan
-
This is called the "handshake problem" (or, more broadly, permutations and combinations). Look it up on wikipedia, the read will benefit the way you think about algorithms. -Dan
-
Warning: usort() expects parameter 2 to be a valid callback
ManiacDan replied to earachefl's topic in PHP Coding Help
Per the usort manual: usort($arrayAll, array($this,"compareLastName")); -
What debug steps have you tried? What's in POST? Are you sure the domain is right? //etc. -Dan
-
Don't write your own date functions. PHP has DateTime::diff. MySQL has DATEDIFF. There is absolutely no reason for you to attempt to write your own date/time functions. This is how you build a calendar: Each "event" entry has an "event date," plus a title and a description. Select all the events from a specific month you wish to display. Sort by start date. Loop through the days of the month (using PHP) and print the calendar, moving to a new row once you hit a the end of the week. Use the PHP functions strtotime and date to determine what day of the week you're on. For each day, check to see if there are any events in your result set that fall inside that day. If so, print them. You should be able to make a calendar without any hard-coded days of the month. This MySQL table is completely unnecessary, I recommend you delete it now. -Dan
-
After Refresh the Input Gets Inserted AGAIN in the Database!
ManiacDan replied to chaseman's topic in PHP Coding Help
Redirect back to the same page with a $_GET variable that instructs the page to print the success message. If you don't destroy $_POST, refresh will re-submit. -Dan -
Why would you design a database like this? Are you planning on the number of days in March changing in the near future? Are you going to run a calendar that's different from everyone else's? To my knowledge, there is no way to easily write this query. You COULD use a very (very) long series of IF statements that progressively add 1 to a variable if the column is populated for a specific row, but you'd have to build the query itself in PHP anyway. MySQL offers the DATEDIFF function, but your table is very poorly constructed...and you don't actually NEED a table to use the datediff function. -Dan
-
You can also look up Snoopy, it's a PHP class that masquerades as a browser. It handles cookies, redirects, and user-agent for you. -Dan
-
Agreed with BlueSky, look up "third normal form" on wikipedia and read about how to properly design a normalized database. -Dan
-
Download Firebug for Firefox, use it to check to see if your CSS file is still loading properly. -Dan
-
I've edited all your posts to remove the references to your site. Definitely listen to Pika (since he's mentioned it twice). $_get is not a variable, $_GET is. -Dan
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=320602.0
-
PHP, like Perl, has a "no complaints mode." Use this line to turn error-reporting on: error_reporting(E_ALL); Put that at the top of your script, or edit your PHP.ini file, and you'll see all the errors you've been missing. Also, as a side note, it's possible to make a function argument optional in PHP by supplying it with a default value: function myFunc ( $a = "Hello, World!" ) {} -Dan
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=318532.0
-
$category_list = " "; That is where the string is started. Change it to: $category_list = "<h1>Fits these products</h1>"; -Dan
-
Fenway is right, that was a general observation about searching, not necessarily for your simplified example.
-
Look into the MATCH ... AGAINST syntax, or split the search terms into an array and do a string of (OR field LIKE '%red%' OR field LIKE '%car%') -Dan
-
Record the click time of the button somewhere (sessions or database). Every time they click, check to see if there's a previous click from them less than 24 hours ago. The session will expire when they close their browser, and the database must be linked to their account somehow (unless this button is global and can only be clicked by anyone once a day. -Dan
-
Look into the class PHPMailer, it will handle all of that for you. Also note that you set $from and then immediately overwrite it with the CC. You want the dot-equals operator (.=) for concatenating strings. -Dan
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=317365.0
-
You cannot tell how long a user spends on the page using pure PHP. You'll have to use a javascript function that "checks in" with the server and updates the timestamp every few seconds. However, there's not really a need for this, as leaving the window open in the background would break your stats. -Dan
-
You have no form tag or submit button, do you have those?