I am attempting to put all my database connections in 1 php file, rather than in each of my individual php pages. I have the following:
//conn.php:
<?php
class conn {
var $username = "name";
var $password = "password";
var $server = "localhost";
var $port = "3306";
var $databasename = "db";
var $tablename = "tablename";
var $connection;
public function getConnected() {
$this->connection = mysqli_connect(
$this->server,
$this->username,
$this->password,
$this->databasename,
$this->port
);
}
}
?>
// file.php:
<?php
require_once("conn.php");
class myClass{
public function con() {
$conn = new conn();
$conn->getConnected();
}
public function myF() {
$stmt = mysqli_prepare($conn->connection, "SELECT * FROM $conn->tablename");
mysqli_stmt_execute($stmt);
}
}
?>
I then call this as follows:
$myNew = new myClass();
$myNew-con();
$myNew-myF();
When I call this, I get the following error:
Undefined property: myClass::$connection
What am I doing wrong?
I know that by default ASP.NET ships with LocalSqlServer... I just uploaded my website and I did the following:
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=winsqlus03.lxa.perfora.net,1433; Initial Catalog=db323219488; User ID= dboxxxxxxxxx; Password=xxxxx;"/>
And inside my App_Data I still have the ASPNETDB.MDF, when I tried to run it... What I got is:
Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
why is this?
I have data composed of a list of employers and a list of workers. Each has a many-to-many relationship with the other (so an employer can have many workers, and a worker can have many employers).
The way the data is retrieved (and given to me) is as follows: each employer has an array of workers. In other words:
employer n has:
worker x, worker y etc.
So I have a bunch of employer objects each containing an array of workers.
I need to transform this data (and basically invert the relationship). I need to have a bunch of worker objects, each containing and array of employers. In other words:
worker x has:
employer n1, employer n2 etc.
The context is hypothetical so please don't comment on why I need this or why I am doing it this way. I would really just like help on the algorithm to perform this transformation (there isn't that much data so I would prefer readability over complex optimizations which reduce complexity). (Oh and I am using Java, but pseudocode would be fine). Thanks!
we know algorithm how reverse array of n integers
for (int i=0;i<n/2;i++){
swap(a[i],a[n-1-i]):
}
is this method better according the speed of algorithm or not because swap using xor is more fast then in other method
here is code
public class swap {
public static void main(String[]args){
int a[]=new int[]{2,4,5,7,8,11,13,12,14,24};
System.out.println(" array at the begining:");
for (int i=0;i<a.length;i++){
System.out.println(a[i]);
}
for (int j=0;j<a.length/2;j++){
a[j]^=a[a.length-1-j];
a[a.length-1-j]^=a[j];
a[j]^=a[a.length-1-j];
}
System.out.println("reversed array:");
for (int j=0;j<a.length;j++){
System.out.println(a[j]);
}
}
}
Result:
array at the begining:
2
4
5
7
8
11
13
12
14
24
reversed array:
24
14
12
13
11
8
7
5
4
2
Hello,
I am binding a collection of MyItem class instances to a DataGrid. The MyItem class has a property called "IsSelected". This property can get changed programmatically. How do I propogate that change back to the UI such that if this value is true, the row associated with MyItem is highlighted (selected) and if it is false, the row associated with MyItem is not highlighted?
Thank you,
I am working on raspberry PI and on Bluetooth. I am using old raspberry pi kernel as the new one has got some bugs that were not resolved with respect to the bluez daemon. At present my kernel version is 3.6.11.
I am using a USB bluetooth dongle and my sole purpose is to auto connect the bluetooth dongle when ever it is in range. For that i think i have to run a script in the backend on RPI that will keep on checking the existence of usb bluetooth dongle. I started from the very scratch. I installed bluez daemon using
apt-get install bluetooth bluez utils blueman
and then i used
hciconfig
which gives me that my bluetooth usb dongle is working fine. But when i did
hcitool scan
, it give me no device in range even though my Serial bluetooth Device was on. I wasn't able to find any device in vicinity. Also when i unplugged and plug the USB dongle again, i was able to scan the serial device , but when i repeat the process, i find the earlier condition of not finding any deice. I had find another useful link, but that need address of the bluetooth device that need to be connected. I want to automate this using hcitool scan, storing the output to the a file and then comparing it with already paired devices and their name. For that i need to figure out why hcitool scan is sometime working and sometime not. ?
Can some one help me in figuring out why this is happening. Is there any problem on
hardware side i.e Bluetooth dongle is buggy or i had some problem in bluez utils.
Edit 1: While as of now, hcitool scan is giving me my remote device address but still i am getting the same issue of HOUST IS DOWN, '/dev/rfcomm1'. I am really not getting any idea of what to be done.
If I need a php-page to have access to upload images and move images from a folder on the server, what permissions would I set on the folder then?
I know we have "Owner", "Group", and "Others".
But what does the server (or the php-code itself) count as? Owner?
Also, would I need to set the php-page with the upload script with some specific permissions to be able to upload the files? Is it execute permissions?
Thanks
Write program that has two threads one is reading numbers from the user and the other is printing them such that the first thread reads a new number only after it has been printed by the second thread. Declare one global varaible to use for reading and printing.
How do I show the dates number format next to its name in the array using PHP? So that the number format is saved in the database and the month name is displayed?
Here is the php code.
$month_options = array("Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
I have the following rewrite rule
rewrite ^/ab(.*)/(.*)$ /repo/ab$1/rtest/$2 break;
When the request file is /abname/index.php it gets rewritten to /abname/rtest/index.php
But if the request is of the form /abname/dir1/index.php it gets rewritten as /abname/dir1/rtest/index.php but I would want it to be rewritten as /abname/rtest/dir1/index.php
How do I write the rule ?
my_window.document.write('
<script type="text/javascript">
function redirect(linkid) {
opener.location.href=linkid;
window.close();
}
</script>
<h1>Hello</h1>
<p>Thank you.If you accidentally closed our website click
<a href="javascript:redirect('http://google.com')">here</font></a>
to go back to our website</p>
');
This is my piece of code to close a already opened pop up window by redirecting it to google.com. I think there is some problem with matching the apostrophes ' and "... how to code with (' (" (' ') ") ')... is this correct? please help me with this.
Please help me with the necessary changes wherever required.
I have a base class MessageHandler and 2 derived classes, MessageHandler_CB and MessageHandler_DQ.
The derived classes redefine the handleMessage(...) method. MH_DQ processes a message and puts the result in a deque while MH_CB processes the message and then executes a callback function.
The base class has a static callback function that I pass along with a this pointer to a library which calls the static callback when a new message is available for processing.
My problem comes when I am in the static callback with a void * pointing to either a MH_DQ or a MH_CB. If I cast it to the base class the empty MessageHandler::handleMessage(...) method is called, rather than the version in the appropriate derived class.
What is the best way to address this situation from a design perspective and/or what language features might help me to implement a solution to my problem?
Thanks in advance!
hello
does Display:none or jquery Hide function speed up my website, i mean i'm developing a website where i have a DIV but it's not always needed so if a give him CSS property Display:none or using jquery .Hide will that speed up my website ? if not how to do that?
Thanks
I have an application which reads the data from the database, creates an object out of the data, marshalls it into an xml and enqueue the xml to a queue which is producer. The xml is dequeued from the queue by a consumer.
I need to use xsds at two different places.
For database access while reading the data from the database and
For interaction between producer and consumer
Can the same xsd be used in both the cases? Or do I need to use different xsds?
In java, when you pass an object to a method as a parameter, it is actually passing a reference, or a pointer, to that object because objects in Java are references.
Inside the function, it has a pointer to that object which is a location in memory. I am wondering where this pointer lives in memory? Is a new memory location created once inside the function to hold this reference?
I want to detach the custom event but could not detach. Please find below I am using -= to detach the event. I assume after this, TextChanged2 method should not be invoked as I have unregistered the event. Let me know if my understanding is wrong.
public delegate void TextChangedEventHandler1(object sender, TextBoxargs ta);
public event TextChangedEventHandler1 TextChanged1;
private void textBox1_TextChanged(object sender, EventArgs e)
{
this.TextChanged1 -= new TextChangedEventHandler1(TextChanged2);
TextChanged2(sender, e);
}
public void TextChanged2(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text.ToUpper();
}
I have a user document which has a group field. This field is an array of group ids. I would like to write a view that returns (groupid as key) - (array of user docs as val). This mapping operation seems like a good beginning.
function(doc)
{
var type = doc.type;
var groups = doc.groups;
if(type == "user" && groups.length > 0)
{
for(var i = 0; i < groups.length; i++)
{
emit(groups[i], doc);
}
}
}
But there's obviously something very wrong with my attempt at a reduce:
function(key, values, rereduce)
{
var set = [];
var seen = [];
for(var i = 0; i < values.length; i++)
{
var _id = values[i]._id;
if(seen.indexOf(_id) == -1)
{
seen.push(_id);
set.push(values[i]);
}
}
return set;
}
I'm running CouchDB 0.10dev. Any help appreciated.
Got a great answer earlier, but unfortunately, I didn't explain the WHOLE situation:
I need to rewrite:
blog.domainname.com/archives/YYYY/MM/postname/
and
www.blog.domainname.com/archives/YYYY/MM/postname/
to
www.domainname.com/blog/postname/
Thanks in advance!
We have developed a ASP.NET web application and has implemented a custom authentication solution using active directory as the credentials store. Our front end application uses a normal login form to capture the user name and password and leverages the Win32 LogonUser method to authenticate the user’s credentials. When we are calling the LogonUser method, we are using the LOGON32_LOGON_NETWORK as the logon type.
The issue we have found is that user profile folders are being created under the C:\Users folder of the web server. The folder seems to be created when a new user who has never logged on before is logging in for the first time. As the number of new users logging into the application grows, disk space is shrinking due to the large number of new user folders getting created.
Has anyone seen this behavior with the Win32 LogonUser method? Does anyone know how to disable this behavior?
I have tried LOGON32_LOGON_BATCH but it was giving an error 1385 in authentication user.
I need either of the solution
1) Is there any way to stop the folder generation.
2) What parameter I need to pass this to work?
Thanks
i have a table like this:
1 x y
2 a
3 b
4 c d e
i want to use a sql statement to turn it into this:
1 x
1 y
2 a
3 b
4 c
4 d
4 e
i am having trouble building the sql statement. please help!