Solved

in odbc_connect(), what username and password we need to enter, please tell me in detail?

Posted on 2009-05-03
16
300 Views
Last Modified: 2012-05-06
in odbc_connect(), what username and password we need to enter, please tell me in detail?
0
Comment
Question by:designersx
  • 9
  • 5
  • 2
16 Comments
 
LVL 4

Expert Comment

by:ValleyENT
ID: 24292543
the database username and password must be entered nothing relating to the computer you are working on, but the username and password you enter for the database must have access.
0
 

Author Comment

by:designersx
ID: 24292558
if i have uploaded my files on ftp.designerx.com , so it need that password.


am i right?
0
 
LVL 4

Expert Comment

by:ValleyENT
ID: 24292564
What are you trying to accomplish, need a bit more detail here.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:designersx
ID: 24292573
when i run this code on localhost, msg comes connection is valid
but on server msg comes, error in the connection.

there is a problem in username and password.
<?php
echo $conn=odbc_connect('win.mdb','','');
if($conn)
	echo "connection is valid";
else	
	echo "error in the connection".odbc_error();
exit;
 
}
?>

Open in new window

0
 

Author Comment

by:designersx
ID: 24292650
i did this with asp and IIS, then it was running there and no username and password was there.

why is this? please help.
0
 

Author Comment

by:designersx
ID: 24292768
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db2.mdb")

this was the line i wrote when i made a connection with mdb database. i was successful inmaking a connection with mdb but i php i am not able to make a conection with mdb database on the server.

why is this so, it is eating me, please help me in this some how?
0
 

Author Comment

by:designersx
ID: 24293790
sir i am using wamp server but i am uploading on iis windows server, so would my code be changed to make a connection on iis server?
0
 

Author Comment

by:designersx
ID: 24294698
ok i have been able now to run on server, can u just tell me how can i count the total no. of rows in the below code. that's it.
<?php
 
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
    
        $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\\wamp\\www\\fantaay\\php_with_mdb\\2\\mydb.mdb");
    
        $q="SELECT myfield FROM mytable";
        
        $rs = $conn->Execute($q);
   
    while (!$rs->EOF) {
   
    $fv = $rs->Fields("myfield");
    
        echo "Value: ".$fv->value."<br>\n";
   
    $rs->MoveNext();
    
        } 
   
    $rs->Close(); 
 ?>

Open in new window

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 24297267
to count, you have 2 options:

option 1
<?php
 
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
    
        $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\\wamp\\www\\fantaay\\php_with_mdb\\2\\mydb.mdb");
    
        $q="SELECT count(*) res FROM mytable";
        
        $rs = $conn->Execute($q);
   
        if (!$rs->EOF) {
           $fv = $rs->Fields("res");
           echo "Value: ".$fv->value."<br>\n";
        }
        else {
           echo "no rows<br/>\n";
        }
   
        $rs->Close(); 
 ?>

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24297283
option 2:

<?php
 
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
    
        $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\\wamp\\www\\fantaay\\php_with_mdb\\2\\mydb.mdb");
    
        $q="SELECT myfield FROM mytable";
        
        $rs = $conn->Execute($q);
        $row_count = 0;
   
    while (!$rs->EOF) {
    $row_count++;
    $fv = $rs->Fields("myfield");
    
        echo "Value: ".$fv->value."<br>\n";
   
    $rs->MoveNext();
    
        } 
   
    $rs->Close(); 
        echo "Rows: ".$row_count."<br>\n";
 ?>

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24297298
in regards to the original question,
did you already check for some suggestions here:
http://php.net/odbc_connect
aka, instead of the .mdb file, you need to specify a DSN entry (on the server) that maps to the .mdb file (as seen on the server)
0
 

Author Comment

by:designersx
ID: 24301576
thanks for tha above code, working.

now can u tell me
>>instead of the .mdb file, you need to specify a DSN entry (on the server) that maps to the .mdb file (as seen on the server)

i was actually geting confused by this, where do i need to make a entry for dsn.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24301685
on the (i presume windows) server, control panels, odbc administrator.
create a system dsn entry with ms access driver, and configure the path to the .mdb file.

the dsn name is what you use in your odbc_connect(dsn_name, '', '');
0
 

Author Comment

by:designersx
ID: 24301715
yes sir , i got it thanks for this but 1 last question. i am not getting any browse button or something else or could i write by myself to give it a path for the mdb file,

there is a dropdown showing me where i need to give the path.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24301735
I have a browse button on the configure screen of the ms access dsn ...
please show the relevant screen shot .
0
 

Author Comment

by:designersx
ID: 24301837
yes sir got it, don't know what happened to me, just a stupid question i ask from you. thanks for the whole help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question