-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
php mail() - addresses with hyphens not being received
JonnoTheDev replied to wrathican's topic in PHP Coding Help
Check the server maillog to see why the message is not going. I can only guess it it reading the hyphen as a switch. -
Wouldnt use a textfield for date input. You will end up with malformed dates if the user changes the values. Use 3 fields day, month, year. Better as select elements.
-
Lucene can do this. Part of the Zend Framework. Requires no db, uses file storage. Will need to implement methods of updating the index.
-
How can it possibly know the pages if the page text is not stored anywhere?
-
Not really possible for me to put entire code here. If you are not familiar with OO its best to do some tutorials on classes, objects, etc A user class may look along the following lines: class login { public static function authenticate($username, $password) { // run an sql query here to get the user mysql_query(); // if the user is found return a new user object if($numrows) { return new user($row['userId']); } else { // invalid login return false; } } } class user { public $name; public function __construct($id) { // query here to get user details from the user id mysql_query(); // set the class variables $this->name = $row['name']; } public function updateUsername($name) { $this->name = $name; // sql to update users name mysql_query(); } } // User has attempted login if(!$user = login::authenticate($username, $password)) { print "Your login failed"; } else { $_SESSION['user'] = $user; } // print the current users name print $_SESSION['user']->name; // set a new name for the user $_SESSION['user']->updateUsername("Joe Bloggs"); // will now print joe bloggs print $_SESSION['user']->name; This is very rough. If you are storing lots of data about a user then you would probably store it in arrays within the class and have setter and getter methods.
-
Not possible
-
Yeah, you could do that but its a pain in the arse if you add extra fields, you would have to add these extra session variables all over your script. Thats why an OO approach is better. If the user class is stored in a session you may take the following approach: $_SESSION['user']->updateAddress(); $_SESSION['user']->updateUsername(); $_SESSION['user']->updateEmail(); etc... The example methods will update the class variables and also update your database records. You may get data using the following: print $_SESSION['user']->get("email");
-
1. When you want to select all rows ONLY! Each field type has a space in memory, the more fields you select the more memory used to return them. 2. If you login to a webiste and your user data is returned you are best storing this in a session. I prefer to create a user object that is returned on successful validation of a user login and stored in a session. I can then use its internal methods to obtain the user data I require on certain pages of the site. This approach means that I do not have to query the users table every time I need data, lets say if you only stored the users ID in a session.
-
Because the query is still valid! You want to throw your exception if there are no rows returned if (!mysql_num_rows($rsltNews)) { throw new Exception("error"); }
-
WOW, and your pretty new to php! This isnt going to be easy. To start with you cant upload folders, this isnt a PHP limitation but a web browser limitation, you cant select a folder for upload. You could upload a zip/gz file and then unpack it after upload. To generate thumbnails you need an image processor. Imagemagick is your best bet. You will also need XML libraries to create your XML files. PHP DOM can do this. Some R+D needed to get you started
-
Escaping the # sign - please help!!!
JonnoTheDev replied to ekgartdirector's topic in PHP Coding Help
$value = str_replace("#","", $value); -
This could be a DNS issue. Does your server resolve names properly? If you take out the email part of the script so its just the database insert does the script run quickly?
-
can you send a file with the mail function?
JonnoTheDev replied to styler's topic in PHP Coding Help
Not designed for attachments. Use PEAR::Mail_Mime http://pear.php.net/package/Mail_Mime -
Try using the server IP address or the IP that your domain name resolves to.
-
How to stop people from viewing my site.
JonnoTheDev replied to ballhogjoni's topic in PHP Coding Help
Try http://www.phpclasses.org/browse/package/1477.html -
Nice, never seen that function
-
use the preg_match() function
-
How to add a blank option to this select field
JonnoTheDev replied to 86Stang's topic in PHP Coding Help
Try this $project_qry = "SELECT * from tbl_projects order by project_name asc"; $project_result = mysql_query($project_qry) or die ("Error during query."); $project_drop = "<select name=\"task_project_id\">\n<option value=\"\"></option>\n"; while ($row = mysql_fetch_array($project_result)) { $project_drop .= "<option value=\"$row[project_id]\">$row[project_name]</option>\n"; } $project_drop .= "</select>\n"; -
You could also take a look at phpOpenTracker http://www.phpopentracker.de/
-
You could get this information from your access logs, or the way I implement this is to use a tracking session or cookie. Have a session that records the page a user is on. $_SERVER['PHP_SELF']; When a page is accessed the session will store the time time(); that the page was requested. When the user then clicks to another page again the session records the request time therefore allowing you to calculate the time difference between requests which is the total time the user spent on the page. You can save this information to a database and even track a users path throughout your site. This is useful for testing the quality of your pages that may lead to a sale if you have an e-commerce site. For instance most sales are made when a user clicks on page x as the next request they make is the payment page, but users tend to leave the site when they reach page y, etc..
-
Email attachment 2nd file is not showing up in the email
JonnoTheDev replied to hhstables's topic in PHP Coding Help
To be honest with you your code is a bit of a mess and the mail() function within php is not meant for attachments. If you want to send email including attachments then use PEAR::Mail Mime. So much easier! Package found at: http://pear.php.net/package/Mail_Mime -
The young text and instant messaging generation, painful!
-
print $_SERVER['SCRIPT_FILENAME'];
-
This is a bit of a double edged sword because open source code is as it says on the tin. If someone finds a weakness in an open source application then all users of it are at risk until a patch is released and thats if users install it. Holes have been discovered in versions of osCommerce before.
-
PHP can save images to your server but not trigger a scanner or any input/output devices