Hello guys I've got a mass mail function that sends e-mail to all emails in my mysql table. but theyr all goes spam. I want to use smtp validate for this function. How can I use smtp validation with "mail($email, $subject, $message, $headers);" ?
thank u
Hi!
I am using some XML parser to get some information from API, blah blah... :)
In one place in my script, I need to convert string to int but I'm not sure how...
Here is my object:
object(parserXMLElement)#45 (4) {
["name:private"]=>
string(7) "balance"
["data:private"]=>
object(SimpleXMLElement)#46 (1) {
[0]=>
string(12) "11426.46"
}
["children:private"]=>
NULL
["rows:private"]=>
NULL
}
I need to have this string "11426.46" stored in some var as integer.
When I echo $parsed->result->balance I get that string, but if I want to cast it as int, the result is: 1.
Please help!
Thanks a lot!
Hello,
I'm hoping somebody knows the answer :).
Within wordpress in the users section I would like to add a new row which will data pulled in from the Register Plus plugin.
Where would I need to create a new row?
My Example:
Username Name E-mail Role **Website** Posts
Admin Admin [email protected] Administrator google.com 2
Thanks.
I need to extract the name of the direct sub directory from a full path string.
For example, say we have:
$str = "dir1/dir2/dir3/dir4/filename.ext";
$dir = "dir1/dir2";
Then the name of the sub-directory in the $str path relative to $dir would be "dir3". Note that $dir never has '/' at the ends.
So the function should be:
$subdir = getsubdir($str,$dir);
echo $subdir; // Outputs "dir3"
If $dir="dir1" then the output would be "dir2". If $dir="dir1/dir2/dir3/dir4" then the output would be "" (empty). If $dir="" then the output would be "dir1". Etc..
Currently this is what I have, and it works (as far as I've tested it). I'm just wondering if there's a simpler way since I find I'm using a lot of string functions. Maybe there's some magic regexp to do this in one line? (I'm not too good with regexp unfortunately).
function getsubdir($str,$dir) {
// Remove the filename
$str = dirname($str);
// Remove the $dir
if(!empty($dir)){
$str = str_replace($dir,"",$str);
}
// Remove the leading '/' if there is one
$si = stripos($str,"/");
if($si == 0){
$str = substr($str,1);
}
// Remove everything after the subdir (if there is anything)
$lastpart = strchr($str,"/");
$str = str_replace($lastpart,"",$str);
return $str;
}
As you can see, it's a little hacky in order to handle some odd cases (no '/' in input, empty input, etc). I hope all that made sense. Any help/suggestions are welcome.
Hi, i'm making a questionnaire about a service quality, its contains the options (poor, regular, good, very good). It's contains 6 questions (radio button) and a suggestion box (textbox).
In the table of the database i created 6 rows for questions, 1 for suggestion and 1 for date (a friend of mine tole me to use this but i didn't get why).
q1) I'm going to atribute a value form 1 to 4 to the radio buttons options, and i'd like to sum every answer for each question, and then divide by the numbers of user that answered that question and give the mean. how am i supposed to to that? I'd also like generate reports of the month, of the year.
q2) not only about the questionnaire but for registration too. I need all the fields to be completed, no blank options, if he don't complete all of fields it'll not be submitted and there will be a warning message to the user.
q3) about the field type, i'd like it to be the same class that is in the database, i'm having a "problem". Ex: Name(varchar) : 1234(int), in the field 'name' of the table of the database 1234 will be shown as name, and i don't want this, i want only the type that i declared in the construction of the table.
q4) i'd also like to know if it's possible to create pizza graphics, about the percentage of each question, is this possible?
q5) I'm using phpmyadmin and some of my id's are auto_increment, but 'cause of my tests they at a high number, i'd like to restart to 0 the ids number, is this possible?
Thanks for the attention.
I'm giving IntiliJ a try, and am looking for something to compare it to. I'm told that I should at least consider it given I use TextMate almost religiously.
I want to get all only youtube video ID from html code
look the (or multiple) object/embed code for youtube video
// html from database
<p>loremm ipsum dolor sit amet enot
<a href="link" attribute=""blah blah blah">anchor link</a>
</p>
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"
type="application/x-shockwave-flash"
allowscriptaccess="always"
allowfullscreen="true"
width="425"
height="344">
</embed>
</object>
<image src="path/to/image.ext" >
<p>lorem ipsum dolor sit amet... blah</p>
<p>lorem ipsum dolor sit amet... blah</p>
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/Ou5eVl5eqtg&hl=es_ES&fs=1&"
type="application/x-shockwave-flash"
allowscriptaccess="always"
allowfullscreen="true"
width="425"
height="344">
</embed>
</object>
<p>blah</p>
blah<br/>
blah<br/>
blah<br/>
How can I know during runtime that my code threw a Warning?
example
try {
echo (25/0);
} catch (exception $exc) {
echo "exception catched";
}
throws a "Warning: Division by zero" error that i can not handle on my code.
Ok, well, I just want to use strip_tags function on the very end of a string to get rid of any <br /> tags.
Here's what I have now, but this is no good because it strips these tags from everywhere in the string, which is not what I want. I only need them stripped out if it's at the end of the string...
$string = strip_tags($string, strtr($string, array('<br />' => ' ')));
How can I do this same thing, except only at the very end of a string??
Thanks guys!!
What does an exclamaton mark in front of a variable mean? And how is it being used in this piece of code?
EDIT: From the answers so far I suspect that I also should mention that this code is in a function where one of the parameters is $mytype ....would this be a way of checking if $mytype was passed? - Thanks to all of the responders so far.
$myclass = null;
if ($mytype == null && ($PAGE->pagetype <> 'site-index' && $PAGE->pagetype <>'admin-index')) {
return $myclass;
}
elseif ($mytype == null && ($PAGE->pagetype == 'site-index' || $PAGE->pagetype =='admin-index')) {
$myclass = ' active_tree_node';
return $myclass;
}
elseif (!$mytype == null && ($PAGE->pagetype == 'site-index' || $PAGE->pagetype =='admin-index')) {
return $myclass;
}`
I need to split html document on two parts. First part, should contain N(30) words, and next one should contain everything else.
And the main problem, is to prevent splitting tags (description and body of tags).
Give me please suggestions (or if you have already written such function, please share your code), how to realize it! Thanks.
Are there any APIs or libraries that make it easy to generate a calendar for a certain month/year? I need to have some sort of admin interface for a "event planner" part of a CMS for a local youth group and I'm at a loss as to how to generate a decent calendar.
Note: I only need something to generate the calendar HTML, not manage events. I'll be coding that part.
I am looking for free (non GPL is better) SSO framework/library implementation or code samples.
There are many kind of SSO implementation. Sharing cookie, sharing session, one time token, associative accounts, etc, etc. (BTW, any good article compare them?)
Is there any keyword I should google and reuse before before I start to implement our own wheel.
I know OpenID, but which is too much and it is not our need. We rather keep it KISS.
We just want share the credentials of user that could save users from another login form.
How do I get this to not display when you first go to the page???
if ($error) {
echo "Error: $error<br/>";
}
if ($keycode) {
echo "Keycode: $keycode<br/>";
}
Apologies for the wording on this question, I'm having difficulties explaining what I'm after, but hopefully it makes sense.
Let's say I have a class, and I wish to pass a variable through one of it's methods, then I have another method which outputs this variable. That's all fine, but what I'm after is that if I update the variable which was originally passed, and do this outside the class methods, it should be reflected in the class.
I've created a very basic example:
class Test {
private $var = '';
function setVar($input) {
$this->var = $input;
}
function getVar() {
echo 'Var = ' . $this->var . '<br />';
}
}
If I run
$test = new Test();
$string = 'Howdy';
$test->setVar($string);
$test->getVar();
I get
Var = Howdy
However, this is the flow I would like:
$test = new Test();
$test->setVar($string);
$string = 'Hello';
$test->getVar();
$string = 'Goodbye';
$test->getVar();
Expected output to be
Var = Hello
Var = Goodbye
I don't know what the correct naming of this would be, and I've tried using references to the original variable but no luck.
I've come across this in the past, with the PDO prepared statements, see Example #2
$stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (?, ?)");
$stmt->bindParam(1, $name);
$stmt->bindParam(2, $value);
// insert one row
$name = 'one';
$value = 1;
$stmt->execute();
// insert another row with different values
$name = 'two';
$value = 2;
$stmt->execute();
I know I can change the variable to public and do the following, but it isn't quite the same as how the PDO class handles it, and I'm really looking to mimic that behaviour.
$test = new Test();
$test->setVar($string);
$test->var = 'Hello';
$test->getVar();
$test->var = 'Goodbye';
$test->getVar();
Any help, ideas, pointers, or advice would be greatly appreciated, thanks.
Hi all - this is a bit of a newbie question but hoping I can get some guidance. I've been playing around with Eclipse for a couple months yet I'm still not completely comfortable with my setup and it seems like every time I install it to a new system I end up with different results.
What I'm hoping to achieve is (I think) fairly standard.
In my environment I'd like SVN (currently using Subclipse), FTP support (currently using Aptana plugin), debugging (going to use XDebug) and all the usual bells and whistles of development (code completion, refactoring, etc.)
My biggest current issue is how to set up my environment to support both a 'development' and 'production' server. Optimally I would be able to work directly against the dev server (Eclipse on my Vista desktop against the VM Ubuntu dev server) and then push to production server (shared hosting). I'd prefer to work directly against the dev server (with no local project files, just using the Connections provided by Aptana) but I'm guessing this won't allow for code-completoin or all the other bells and whistles provided for development. Any thoughts?
Kind of an open ended question, but maybe this could be an opportunity for some of you with a great deal of experience using Eclipse to describe your setups so people like me can get some insight into good ways to get set up.
I built many a website, and my own 'custom' framework is just a general box of scripts cobbled together with loose ideas. I would love to progress to a framework which allows me to pass it onto the client for freedom.
Someone suggested using wordpress but I'm not sure how general this can be.
A current site I need to build is a fancy kitchen company, price lists, flash gallery (with backend driven pics) and well designed home.
How could I bend the the will of wordpress? Alternatively, does anyone have a suggestion for an alternative.
Thanks in advance guys -
I have an eCommerce platform, and i wand to secure it. How can it be possible ?
I don't want to somebody copy my code. Like a license for 1 year with a code for activation. Or somethings like this. Sorry my English, thanks a lot!
Simple question, how do I convert an associative array to variables in a class? I know there is casting to do an (object) $myarray or whatever it is, but that will create a new stdClass and doesn't help me much. Are there any easy one or two line methods to make each $key => $value pair in my array into a $key = $value variable for my class? I don't find it very logical to use a foreach loop for this, I'd be better off just converting it to a stdClass and storing that in a variable, wouldn't I?
class MyClass {
var $myvar; // I want variables like this, so they can be references as $this->myvar
function __construct($myarray) {
// a function to put my array into variables
}
}
I have zlib and Zend Optimizer enabled on my server.
I have read about the
zlib.output_compression
directive. Are there any caveats with turning this directive on in my server?
I'm now working on a project and I have one class that implements the ArrayAccess interface.
Howewer, I'm getting an error that says that my implementation:
must be compatible with that of ArrayAccess::offsetSet().
My implementation looks like this:
public function offsetSet($offset, $value) {
if (!is_string($offset)) {
throw new \LogicException("...");
}
$this->params[$offset] = $value;
}
So, to me it looks like my implementation is correct. Any idea what is wrong? Thanks very much!
The class look like this:
class HttpRequest implements \ArrayAccess {
// tons of private variables, methods for working
// with current http request etc. Really nothing that
// could interfere with that interface.
// ArrayAccess implementation
public function offsetExists($offset) {
return isset ($this->params[$offset]);
}
public function offsetGet($offset) {
return isset ($this->params[$offset]) ? $this->params[$offset] : NULL;
}
public function offsetSet($offset, $value) {
if (!is_string($offset)) {
throw new \LogicException("You can only assing to params using specified key.");
}
$this->params[$offset] = $value;
}
public function offsetUnset($offset) {
unset ($this->params[$offset]);
}
}