If I don't know the public web directory, is there a way my script could determine the web directory, so that the script would know which directory to upload the file to?
Hey.
I was coding here the other day, writing a couple of if statements with ints that are always either zero or one (~bools), and I asked myself:
Should I use if (int == 1) or if (int != 0) ?
Is there any difference at all?
Please, don't answer with stuff regarding the int may being more/less than 1/0, that's not what I want to know.
Hi, im having problems starting a codeigniter project, the problem is that when i do something in a controller and then i want a page to display the result, an example: i have a form to add a item to the database, i get all the data in the controller and save it to database and then i want (if all went well) to redirect to the main page with a success msg, i was doing this with
$this->load->view('admin', $data);
the problem is that the url keeps saying admin/addItem so everytime the page gets refreshed it adds another item, now i found the:
redirect('admin','refresh');
but this only helps me when i dont need to display any msg because this function dont allow to send a $data var.
Any ideas?
Probably this is really easy to fix but i cant find a way to handle the flow of the application the way i want, any help is apreciated.
thanks ;)
Hello, how I can use array acces with my static class?
F.e. I like to execute next script:
class A {
...
}
A['p'] = 15;
echo isset(A['p']) ? A['p'] : 0;
i've got a variable $user that is of data type User (a class).
i've got it in a class method so i can't just type:
/**
* @var User
*/
$user = Factory::getInstance('User');
because that will work only with class properties, not method variables like in this case.
how could i tell netbeans that that variable is of data type User in a method?
Thanks!
Hi
I have code where I connected to the database like so:
$db = new mysqli("localhost", "user", "pass", "company");
Now when I query the database like so:
//query calls to a stored procedure 'user_info'
$result = $db->query("CALL user_info('$instruc', 'c_register', '$eml', '$pass', '')");
//I use the $result
This query works well. Now when I try and free that result like so:
$result->free();
or
$result->close();
It seems like it doesn't do anything because $result is still set. When I try to run another query it gives me this error:
Fatal error: Call to a member function fetch_array() on a non-object in...
For me to run this other query I have to close the db conection and connect again, then it will work. I want to know if there is a way I could run the other query without having to disconnect and reconnect to the database.
thanks in advance.
I have a largish array of string that I want to use as a lookup.
I a using in_array(), but I suspect its doing a simple loop through - does anyone know whether the in_array() algo uses a bsearch algo?
Given original codes as:
foreach($option as $name=>$value)
$array[$name] = $value;
and some $name as
button[0][text], button[0][value], button[1][text], spider[0][name], ...
How could i get results as
$array[button][0][text] = $value
...
$array[spider][0][name] = $value ?
...
The last time I worked with Zend_Db I recall I used to write SQL Queries manually. I've been searching for some ORM application, but, since I read something like Zend_Db is also capable of doing so, I started to try it, but I can't find neither a good tutorial explain it or a good documentation.
I read something lake Gateway pattern and ModelMapper class but I can't figure it out.
Can someone shine my path? :P
We are a growing network but we figured we want to keep that the User only would need one account in order to access the network different sites. (Similar to Stackoverflow's login, If you login in to another "site" you use your account credentials and than your account is created). We want our own login system (Username, password) and not OpenId, as we'd probably have that in the future, but the main focus right now is the global login.
How can I do this? Do a Curl request and send back a cookie? Have a "database" just for the login procedure and on first login also create a new "User" in the site specified database?
Suggestions?.
The following code will add the categories selector widget to the WordPress Page editor interface...
add_action('admin_menu', 'my_post_categories_meta_box');
function my_post_categories_meta_box() {
add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'page', 'side', 'core');
}
What I would like to do is to figure out how to modify the resulting category listing so that it only contains a predefined list of hard coded categories that I define.
Since I'm adding this via my custom theme, it will only appear on the page editor when my theme is active on the site. And I have some specific "handler" categories that my theme installs into the site and later uses to determine layout elements.
I am able to retrieve Orkut contacts but when i send the message, the message is not being sent to the persons although it is showing -Invites sent successfully!.
In Myspace-It is showing-Unable to get contacts ! when i try to get the contacts.
Can somebody help me out?
I'm trying to install imageMagick but i've got practically zero server knowledge,
i don't get what this means:
You can easily install Imagemagick on
a cPanel by using cPanel script.
/scripts/installimagemagick will do it
for you.
what is this /scripts business, where do i type it? do i type it? what's this all about?!!!
http://geobaby.in/installing-imagemagick-on-a-cpanel-server/
i am working on a webapp to download videos from streaming websites.
i don't know anything about applets but stuck here to know about them.
anybody please give basic detailed method to create such applet and how to use it?
I have my own server (with root access).
I need statistics of users who visit my website etc etc...
I have looked at an app called Webalyzer...
Is this a good choice?
I run apache2 on a Ubuntu 9 system...
If you know of any good statistics apps for servers please let me know.
And a follow-up question: All statistics are saved in log-files right? So how large would these log-files become then? Possibility to split them would be good, dont know if this is possible with Webalyzer though...
Got this function for ammending the query string and was wondering what the replacement part of the pre_replace meant (ie- $1$2$4).
function add_querystring_var($url, $key, $value) {
$url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
$url = substr($url, 0, -1);
if (strpos($url, '?') === false) {
return ($url . '?' . $key . '=' . $value);
} else {
return ($url . '&' . $key . '=' . $value);
}
}
Not too familiar with regular expression stuff. I get the various parts to preg_replace but not 100% about the use of '$1$2$4' in the replacement part.
Hello, I have set up an array of censored words and I want to check that a user submitted comment doesn't contain any of these words. What is the most efficient way of doing this? All I've come up with so far is splitting the string into an array of words and checking it against the array of censored words, but I've a feeling there's a neater way of doing this.
This code repeats itself. How can I make it shorter? Maybe by using anonymous function or something?
foreach ($value as $wrong) {
if (starts_with($wrong, '%') and ends_with($wrong, '%')) {
$wrong = trim($wrong, '%');
if (contains($address, $wrong)) {
$corrected_address = str_replace($wrong, $key, $address);
break;
}
}
else {
$wrong = trim($wrong, '%');
if (ends_with($address, $wrong)) {
$corrected_address = str_replace($wrong, $key, $address);
break;
}
}
}
Thanks.
I'm performing a query on a worksheet. I want to update the row if it exists or insert it if it doesn't. How can you check if a result was returned or not?
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($this->currKey);
$query->setWorksheetId($this->currWkshtId);
$query->setSpreadsheetQuery('cid = ' . $data['cid']);
$listFeed = $this->gdClient->getListFeed($query);
// This does not work!
if(empty($listFeed)){
echo 'No results found!';
}
Is there an easy way (or a module) in Drupal to distinguish between anonymous users who have never created an account versus those who are returning but are not currently logged in?
For non-returning (ie, completely new) users, I'd like to have a front page that is very streamlined and focused on registration as the call-to-action. However, if someone is a returning user but not currently logged in, I'd like to present a lot more information on the front page and have login as the main call-to-action. I realize both pages would still need to have both login and register options available, I just want to make the focus significantly different between the two.
Duplicate of http://stackoverflow.com/questions/2803425
Hello,
When a user enters his login information and hits submit, irrespective of whether the login credentials entered by the user were correct or not, i want my function to be called. In this function, i need the username entered by the user.
I think i cannot use the login op of hook_user because its called only when the user has successfully logged in.
So, how can i achieve the above functionality ?
Some sample code would be really appreciated.
Please help.
Thank You.
I converted all mysql tables to utf-8_unicode and started using mysql_set_charset('utf8'); function.
But after this, some characters like S, Ö started looking like Ö , Åž
How can i replace this kinda letters in mysql with UTF-8 format ?
shortly, can i find a list of all these kinda characters to replace ?
EDIT:
He is explaining about this issue in this article actually but i cannot understand it properly acutally lol
http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html