AllSeoHelp.com
Search the Entire Site
  • PHP
  • JavaScript
  • CSS
  • HTML

PHP - Trouble Connecting To Odbc






Topic

Trouble Connecting To Odbc

View Content
I have "UPC" setup as a system dsn, type "CodeBaseOdbcStand", and I can connect to it from access.  However, I am not having success yet using php.  This is a connection to .dbf /.cdx files for data associated with our inventory program.


ERROR
Code: [Select]
PHP Warning:  odbc_connect() [<a href='function.odbc-connect'>function.odbc-connect</a>]: SQL error: [Simba][SimbaEngine ODBC Driver][DRM File Library]No such database., SQL state 08004 in SQLConnect in C:\Inetpub\wwwroot\test.php on line 6

CODE
Code: [Select]
<html>
<body>


<?php
$conn=odbc_connect('UPC','','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM ARUPC";
$rs=odbc_exec($conn,$sql);
if (!$rs)
  {exit("Error in SQL");}
echo "<table><tr>";
echo "<th>UPC</th>";
echo "<th>ITEM</th></tr>";
while (odbc_fetch_row($rs))
  {
  $UPC=odbc_result($rs,"UPC");
  $ITEM=odbc_result($rs,"ITEM");
  echo "<tr><td>$UPC</td>";
  echo "<td>$ITEM</td></tr>";
  }
odbc_close($conn);
echo "</table>";

?>

</body>
</html>



Similar Tutorials

Trouble Connecting To Odbc
Trouble Connecting To Database
Trouble Connecting Search Textbox To Database
Php & Odbc
Odbc Connection Problems
Odbc Connections Not Closing
How To Retrieve Very First Record In Database Using Odbc
How To Establish Database Connection Using Odbc And Php
Transfer Data From Odbc To Mysql With Php
Escaping Apostrophe Using Php/mssql And Odbc
Requesting Help In Php Odbc Stored Procedure Calling
Access Denied For User 'odbc'@'localhost'
Php-odbc Keeps Failing When I Try To Execute Select Statement!
Odbc Query Problem - Undefined Index
Send A Web Table To An Excel Sheet Via Odbc And Sql
How To Connect To A Database On A Live Server Using Odbc Command
Php Login Form With Odbc Connection Toms Access
Query Empty When Trying To Insert Into Database (odbc Connection)
Help Needed Inserting Blobs Via Odbc In Oracle Database
Php Login Form Verifying Username With Odbc Connect To Access
Help On Connecting To Db
Help With Connecting To Localhost
Connecting Mysql With Php
Php Is Not Connecting To Mysql Database?
Problems Connecting To Database.






Trouble Connecting To Odbc

Similar Tutorials View Content
I have "UPC" setup as a system dsn, type "CodeBaseOdbcStand", and I can connect to it from access.  However, I am not having success yet using php.  This is a connection to .dbf /.cdx files for data associated with our inventory program.


ERROR
Code: [Select]
PHP Warning:  odbc_connect() [<a href='function.odbc-connect'>function.odbc-connect</a>]: SQL error: [Simba][SimbaEngine ODBC Driver][DRM File Library]No such database., SQL state 08004 in SQLConnect in C:\Inetpub\wwwroot\test.php on line 6

CODE
Code: [Select]
<html>
<body>


<?php
$conn=odbc_connect('UPC','','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM ARUPC";
$rs=odbc_exec($conn,$sql);
if (!$rs)
  {exit("Error in SQL");}
echo "<table><tr>";
echo "<th>UPC</th>";
echo "<th>ITEM</th></tr>";
while (odbc_fetch_row($rs))
  {
  $UPC=odbc_result($rs,"UPC");
  $ITEM=odbc_result($rs,"ITEM");
  echo "<tr><td>$UPC</td>";
  echo "<td>$ITEM</td></tr>";
  }
odbc_close($conn);
echo "</table>";

?>

</body>
</html>


Trouble Connecting To Database

Similar Tutorials View Content
Never worked with GoDaddy before... Can't get my config script to connect to the database.  Here's my code (I'm sure all the login info is correct, except maybe the host name but I copied that from GoDaddy too...)
<?php
ob_start();
// MySQL connection settings
$db_host = "anakdesigns.db.2089823.hostedresource.com";
$db_user = "********";
$db_pass = "********";
$db_name = "********";
// Connect to the database
$con = mysql_connect($db_host, $db_user, $db_pass) or die("Cannot connect to DB");
mysql_select_db($db_name) or die("Error accessing DB");
?>

http://www.anakdesigns.com/dev



Trouble Connecting Search Textbox To Database

Similar Tutorials View Content
I have a textbox which i want users to be able to search the database for zipcodes, I can't seem to make it work my IDE doesn't show any errors but when I test the code everything goes blank, the mysql credentials are all correct the code is, any suggestions would help

<form action="index.php" method="post">
   <label for="search2" style="color:#FFF;background-color:#0A016D"><b>Search Homes by Zipcode</b></label><br>
 zipcode:  <input type="text" name="zipcode"><br>
   <button type="submit" name="submit" value="submit"/>
   </form>
<?php
    $zipcode= @$_post['zipcode'];
    require("myconn.php");
    mysql_select_db("phplogin")or die(mysql_error());
   $sql= mysql_query("SELECT * FROM users WHERE zipcode='$zipcode' ");
   $numrow= mysql_num_rows($sql);
   while($row= mysql_fetch_assoc($sql))
   {
    echo "zipcode: ".$row['zipcode']." city :".$row['city']."<br/>";
      
   }
   ?>


Php & Odbc

Similar Tutorials View Content
I could really use some help, I'm a new programmer so I'm open to any advice or ideas, but we've created a VFP program and here's what I need...

I need to make an HTML page for people to input information about a contract and then upload files that are associated with that contract. This all needs to be done over the internet of course and I'm not sure if there's a software that would help with this or if ODBC is even the way to go? Right now I'm coming up awfully blank with ODBC...

Any suggestions?


Odbc Connection Problems

Similar Tutorials View Content
Hello, I'm new at PHP programming. I'm creating a simple application. I created a form where users can fill in some data. One of the fields is a username. This is a drop down list. This list is build up with data from SQL Server 2005 R2. I created the code in PHPDesigner7. The ODBC connection is working fine in PHPDesigner7. When I try to run it on the localhost I get no connection
The code I used :

            <?php
                $conn=odbc_connect('MyDataBase','','');
                echo "connectie ".$conn;
                if (!$conn)
                    {exit("Connection Failed: ". $conn);}
       
                $sql="SELECT Id, [Name] FROM Names";
                $rs=odbc_exec($conn,$sql);         
   
                $options="";

                echo "<br />";
                echo "User : ";               
                echo "<select name='QCT_name'>";
               
                while ($row=odbc_fetch_array($rs))
                {
                    $id= $row["Id"];
                    $Controleur = $row["Name"];
                    echo "<option value='".$row['Id']."'>".$row['Name']."</option>";
                }         
                echo "</select>";
                echo "<br />";
               
            ?>

Has anybody any clue what I'm doing wrong?



Odbc Connections Not Closing

Similar Tutorials View Content
Hi

Have an issue with a script that connects to multiple Access databases to extract data.

There is one master database and then numerous small databases (I take no responsibility for the design!). The master is opened and then the sub databases are looped around, opened process and closed in turn.

However after about 20 connections I get the error [ODBC Microsoft Access Driver] Too many client tasks for any new connections. It is related to the number of connections rather than the number of operations on databases (ie, if I comment out one of the pieces of SQL run on each database it makes no difference).

I am closing the connection and unsetting the variable that stores the connection. As such there shouldn't be an excess of connections open at any one time.

Any suggestions?

All the best

Keith


How To Retrieve Very First Record In Database Using Odbc

Similar Tutorials View Content
CAN ANYONE TELL ME WHAT i AM DOING WRONG. I WANT TO RETRIEVE THE VERY FIRST RECORD IN MY DATABASE WHEN THE CODE EXECUTE IT ONLY SHOWS THE LAST RECORD IN THE DATABASE

<?PHP
$thisMonth = date('M');
$thisDay = date('j');
$eventMonth = array();
$eventDay = array();
$eventTime = array();
$eventName = array();
$eventLocation = array();
$dbMonth="";
$dbDay="";

$i=0;

$conn = odbc_connect('eventsDB','','');

$sql= "SELECT month,day, time, event,location FROM Events";
$rs="$conn,$sql";
if (!$conn)
{
   exit("Connection Failed: " . $conn);
}
 $rs=odbc_exec($conn,$sql);

if(!$rs)
{
   exit("Error in SQL");
}
 echo "DATABASE OPEN";
 

while($i<3)
{
   $dbMonth= odbc_result($rs,"month");
   echo $eventMonth[$i]=odbc_result($rs,"month")."\n"; 
   
   
   if($dbMonth<>$thisMonth)
   {
      odbc_fetch_row($rs);   
   
   }
                echo $eventMonth[$i]=odbc_result($rs,"month")."\n"; 
               echo $eventDay[$i]=odbc_result($rs,"day")."\n";
               echo $eventTime[$i]=odbc_result($rs,"time")."\n";
               echo $eventDay[$i]=odbc_result($rs,"event")."\n";
               echo $eventLocation[$i]=odbc_result($rs,"location")."\n";
               $i++;
               odbc_fetch_row($rs);
            
                  
         
   

echo $i;
} //ends while loop
odbc_close($conn);
?>


How To Establish Database Connection Using Odbc And Php

Similar Tutorials View Content
can anyone  give me an example of how to establish an ODBC connection with PHP. I have a MS ACCESS database i want to open and read from

thanks


Transfer Data From Odbc To Mysql With Php

Similar Tutorials View Content
I am having trouble transferring data from provideX ODBC to MySQL using Navicat. So, I am wanting to write a php script that will write all of the data to a text file, then do a MySQL "DATA LOAD INFILE".

I am VERY limited as far as the SQL functions that are available to me with the ODBC connection. The table does not have a special unique identifier other than the item number.

This table I am pulling from has a little over 100,000 items.  How can I get php to process the full 100,000 rows.  I thought about getting it to process 5,000 rows sorted by item #> break > pass the last item to the next page > then process the next batch of 5,000 sorted by item # where the item is greater than the item processed on the last page. ??

Jake

I have not tested this code yet. I just kind of threw it together.
Code: [Select]
<?php
set_time_limit(900);
ini_set('max_execution_time', '999');

$myFile = "item_master.txt";
unlink($myFile);

$fp = fopen("item_master.txt", "w"); 


require("..\inc/data.inc");

if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="SELECT ITEM_NUM, DESCRIPTION_1, DESCRIPTION_2, ITEM_CLASS, ALPHA_SORT, STANDARD_PACK, GL_TABLE, PRIMARY_VND_NUM, VENDOR_ITEM_NUM, ACTIVE, ITEM_PRICE_CLS FROM ic_inventry_mast";

$rs=odbc_exec($conn,$sql);
if (!$rs)
  {exit("Error in SQL");}
while (odbc_fetch_row($rs))
  {
$ITEM_NUM=trim(odbc_result($rs,"ITEM_NUM"));
$DESCRIPTION_1=trim(odbc_result($rs,"DESCRIPTION_1"));
$DESCRIPTION_2=trim(odbc_result($rs,"DESCRIPTION_2"));
$ITEM_CLASS=trim(odbc_result($rs,"ITEM_CLASS"));
$ALPHA_SORT=trim(odbc_result($rs,"ALPHA_SORT"));
$STANDARD_PACK=trim(odbc_result($rs,"STANDARD_PACK"));
$GL_TABLE=trim(odbc_result($rs,"GL_TABLE"));
$PRIMARY_VND_NUM=trim(odbc_result($rs,"PRIMARY_VND_NUM"));
$VENDOR_ITEM_NUM=trim(odbc_result($rs,"VENDOR_ITEM_NUM"));
$ACTIVE=trim(odbc_result($rs,"ACTIVE"));
$ITEM_PRICE_CLS=trim(odbc_result($rs,"ITEM_PRICE_CLS"));


$ITEM_NUM=str_replace('@','',$ITEM_NUM);
$DESCRIPTION_1=str_replace('@','',$DESCRIPTION_1);
$DESCRIPTION_2=str_replace('@','',$DESCRIPTION_2);
$ITEM_CLASS=str_replace('@','',$ITEM_CLASS);
$ALPHA_SORT=str_replace('@','',$ALPHA_SORT);
$STANDARD_PACK=str_replace('@','',$STANDARD_PACK);
$GL_TABLE=str_replace('@','',$GL_TABLE);
$PRIMARY_VND_NUM=str_replace('@','',$PRIMARY_VND_NUM);
$VENDOR_ITEM_NUM=str_replace('@','',$VENDOR_ITEM_NUM);
$ACTIVE=str_replace('@','',$ACTIVE);
$ITEM_PRICE_CLS=str_replace('@','',$ITEM_PRICE_CLS);


$row="$ITEM_NUM@$DESCRIPTION_1@$DESCRIPTION_2@$ITEM_CLASS@$ALPHA_SORT@$STANDARD_PACK@$GL_TABLE@$PRIMARY_VND_NUM@$VENDOR_ITEM_NUM@$ACTIVE@$ITEM_PRICE_CLS\r\n";

fwrite($fp, $row); 

  }
  
  
fclose($fp); 

?>


Escaping Apostrophe Using Php/mssql And Odbc

Similar Tutorials View Content
I am using PHP with ODBC to connect to an existing MSSQL database to query for some names.  When I query a name that has an apostrophe in it, I get an error.

Example typing O'Malley as the name:

Quote

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'malley'., SQL state 37000 in SQLExecDirect



I have used addslashes to the string but get the same result:

Code: [Select]
$string = addslashes($_POST['string']);

$connect = odbc_connect("$mssql_name", "$mssql_user", "$mssql_pass");

$query_mssql = "SELECT pr.NameFirst, pr.NameLast, pr.NameMiddle, pr.Birthdate, p.Barcode, p.OrganizationID
FROM PatronRegistration pr
JOIN Patrons p ON (pr.PatronID = p.PatronID)
WHERE pr.NameLast = '$string'";

$result = odbc_exec($connect, $query_mssql);

Any ideas?


Requesting Help In Php Odbc Stored Procedure Calling

Similar Tutorials View Content
Hi Everyone,

This is Tamilmani Mohan , i have few doubts in SQL Stored Procedure.

I am able to run the SQL SP using odbc driver and also get the result set.

For Example: odbc_exec($connection,"exec get_Members");

I don't know how to run the input / output parameters SP's?

Example:-
If i run the below code by using SQL Management Visual Studio, I am able to insert to new record and get the member id and error code values.

declare @MemberId  int,@Error    int
     
EXEC INSERT_MEMBER 1,'Tamilmani','Mohan','Address1', 'Address2', 'Address3','Salem','Tamilnadu','India',9993234234 , @MemberId  OUTPUT ,  @Error    OUTPUT

SELECT @MemberId , @Error

I don't know how to run this type code in PHP ODBC ?

Kindly , please any one give me good suggestion for this problem ?

Thanks
Tamilmani Mohan


Access Denied For User 'odbc'@'localhost'

Similar Tutorials View Content
Hi,

I found a tutorial in building a poll, however it detects IP, so people can't vote multiple times, so I dissected the code into sections while removing the IP blocking, while still inserting the IP address into the database, the problem is that I get:

Access denied for user 'ODBC'@'localhost'

for the second page, I don't know where I went wrong, could anyone help me? I also attached the code and .sql file so that people can hack it and check where it got wrong.

Thanks

here is the original poll code
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
<?php

//database settings

$hostname = 'localhost';
$username = 'root';
$password = '';
$dbname = 'poll1';

$connect = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname);

//Validation to check if the user has voted or not. If not yet voted, then insert the data to the database, otherwise
//tell the user they voted
if(isset($_POST['vote']) && isset($_POST['questions'])){
$query = mysql_query("SELECT questions.pid FROM responses, questions WHERE responses.qid=questions.id AND responses.ip='".$_SERVER['REMOTE_ADDR']."' AND pid=(SELECT pid FROM questions WHERE id='".$_POST['questions']."' LIMIT 1)");
if(mysql_num_rows($query) == 0){
$query = mysql_query("INSERT INTO responses (qid, ip) VALUES ('".$_POST['questions']."', '".$_SERVER['REMOTE_ADDR']."')");
} else {
$error = 'You Already Voted';
}
} else if(!isset($_POST['questions']) && isset($_POST['vote'])){
$error = 'Please select a response';
}
?>

<?php
//The poll script
$query = mysql_query("SELECT * FROM poll ORDER BY id DESC LIMIT 1");
$rows = mysql_num_rows($query);

if($rows > 0){
$poll = mysql_fetch_array($query);
$title = $poll['name'];
} else {
$title = 'No Poll Yet';
}
$me=array();
$query = mysql_query("SELECT COUNT(id) as hits FROM responses GROUP BY qid");
while($row = mysql_fetch_array($query)){
$me[] = $row['hits'];
}

$max = max($me);


//echo "SELECT questions.pid FROM  responses, questions WHERE responses.qid=questions.id AND responses.ip='".$_SERVER['REMOTE_ADDR']."' AND pid='".$poll['id']."'";

$query = mysql_query("SELECT questions.pid FROM  responses, questions WHERE responses.qid=questions.id AND responses.ip='".$_SERVER['REMOTE_ADDR']."' AND pid='".$poll['id']."'");

if(mysql_num_rows($query) > 0){
$total = mysql_query("SELECT questions.pid FROM responses, questions WHERE responses.qid=questions.id AND pid='".$poll['id']."'");
$total = mysql_num_rows($total);
?>
<table width="300" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center">
<tr>
<td valign="top" align="center" class="title"><h1><?php echo $title; ?></h1></td>
</tr>
<?php
$query = mysql_query("SELECT * FROM questions WHERE pid='".$poll['id']."' ORDER BY id");
$questions = mysql_num_rows($query);
if($questions > 0){
?>
<tr>
<td valign="top" style="padding: 5px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
<?php
while($question = mysql_fetch_array($query)){
$responses = mysql_query("SELECT count(id) as total FROM responses WHERE qid='".$question['id']."'");
$responses = mysql_fetch_array($responses);

if($total > 0 && $responses['total'] > 0){
$percentage = round(($responses['total'] / $max) * 100);
} else {
$percentage = 0;
}

$percentage2 = 100 - $percentage;
?>
<tr>
<td valign="top" nowrap="nowrap"><?php echo $question['question']; ?></td>
<td valign="top" height="10" width="100%" style="padding: 0px 10px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" width="<?php echo $percentage ; ?>%" <?php if($percentage > 0){?>style="background: url('images/bar.jpg') repeat-x;"<?php } ?>><img src="images/dot.gif" width="1" height="19" /></td>
<td valign="top" width="<?php echo $percentage2; ?>%"></td>
</tr>
</table>
</td>
<td valign="top"><?php echo $responses['total']; ?></td>
</tr>
<?php
}
?>
<tr>
<td valign="top" colspan="3" align="center" style="padding: 10px 0px 0px 0px;">Total Votes: <?php echo $total; ?></td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</table>
<?php
} else {
?>
<table width="400" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center">
<th>Declaration of Faith</th>
<tr>
<td valign="top" align="center" class="title"><?php echo $title; ?></td>
</tr>
<?php
$query = mysql_query("SELECT * FROM questions WHERE pid='".$poll['id']."' ORDER BY id");
$questions = mysql_num_rows($query);
if($questions > 0){
?>
<tr>
<td valign="top" style="padding: 5px;">
<form name="poll" method="post" action="">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
<?php
if(isset($error)){
?>
<tr>
<td valign="top" colspan="2" align="center" style="padding: 0px 0px 10px 0px;"><?php echo $error; ?></td>
</tr>
<?php
}
?>
<?php
$x=0;
while($question = mysql_fetch_array($query)){
?>
<tr>
                <?php
if ($x==0){
?>
<td width="43%" rowspan=2 align="center"><span style="padding: 10px 0px 0px 0px;">
    <input type="submit" id="submit" name="vote" value="Declare" />
  </span></td>
<?php }//if statement closing

?>
  <td valign="top" width="56%"><input type="radio" name="questions" value="<?php echo $question['id']; ?>" /><?php echo $question['question']; ?></td>
  </tr>
<?php

$x=$x+1;
}
?>
<tr>
<td valign="top" align="center" style="padding: 10px 0px 0px 0px;"><br /></td>
  <td width="1%">&nbsp;</td>
</tr>

<tr>
<td colspan="2" align="center" id="note">Please answer only once per person</td>
</tr>
</table>
</form>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>


Here are the sectioned codes
insert.php
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
<?php
include('config.php');
//Validation to check if the user has voted or not. If not yet voted, then insert the data to the database, otherwise
//tell the user they voted
if(isset($_POST['vote']) && isset($_POST['questions']))
{
//insert the vote to the database
$query = mysql_query("INSERT INTO responses (qid, ip) VALUES ('".$_POST['questions']."', '".$_SERVER['REMOTE_ADDR']."')");
} 
else if(!isset($_POST['questions']) && isset($_POST['vote']))
{
echo 'Please select a response';
}

include('results.php');
?>



results.php
<?php
//The poll script
$query = mysql_query("SELECT * FROM poll ORDER BY id DESC LIMIT 1");
$rows = mysql_num_rows($query);

if($rows > 0){
$poll = mysql_fetch_array($query);
$title = $poll['name'];
} else {
$title = 'No Poll Yet';
}
$me=array();
$query = mysql_query("SELECT COUNT(id) as hits FROM responses GROUP BY qid");
while($row = mysql_fetch_array($query)){
$me[] = $row['hits'];
}

$max = max($me);

$query = mysql_query("SELECT questions.pid FROM  responses, questions WHERE responses.qid=questions.id AND responses.ip='".$_SERVER['REMOTE_ADDR']."' AND pid='".$poll['id']."'");

if(mysql_num_rows($query) > 0){
$total = mysql_query("SELECT questions.pid FROM responses, questions WHERE responses.qid=questions.id AND pid='".$poll['id']."'");
$total = mysql_num_rows($total);
?>
<table width="300" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center">
<tr>
<td valign="top" align="center" class="title"><h1><?php echo $title; ?></h1></td>
</tr>
<?php
$query = mysql_query("SELECT * FROM questions WHERE pid='".$poll['id']."' ORDER BY id");
$questions = mysql_num_rows($query);
//vote results
?>
<tr>
<td valign="top" style="padding: 5px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
<?php
while($question = mysql_fetch_array($query)){
$responses = mysql_query("SELECT count(id) as total FROM responses WHERE qid='".$question['id']."'");
$responses = mysql_fetch_array($responses);

if($total > 0 && $responses['total'] > 0){
$percentage = round(($responses['total'] / $max) * 100);
} else {
$percentage = 0;
}

$percentage2 = 100 - $percentage;
?>
<tr>
<td valign="top" nowrap="nowrap"><?php echo $question['question']; ?></td>
<td valign="top" height="10" width="100%" style="padding: 0px 10px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" width="<?php echo $percentage ; ?>%" <?php if($percentage > 0){?>style="background: url('images/bar.jpg') repeat-x;"<?php } ?>><img src="images/dot.gif" width="1" height="19" /></td>
<td valign="top" width="<?php echo $percentage2; ?>%"></td>
</tr>
</table>
</td>
<td valign="top"><?php echo $responses['total']; ?></td>
</tr>
<?php
}
?>
<tr>
<td valign="top" colspan="3" align="center" style="padding: 10px 0px 0px 0px;">Total Votes: <?php echo $total; ?></td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</table>



vote.php
<?php
include('config.php');

//vote starts here
?>
<table width="400" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center">
<th>Declaration of Faith</th>
<tr>
<td valign="top" align="center" class="title"><?php echo $title; ?></td>
</tr>
<?php
$query = mysql_query("SELECT * FROM questions WHERE pid='".$poll['id']."' ORDER BY id");
$questions = mysql_num_rows($query);
?>
<tr>
<td valign="top" style="padding: 5px;">
<form name="poll" method="post" action="results.php">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
<?php
$x=0;
while($question = mysql_fetch_array($query)){
?>
<tr>
                <?php
if ($x==0){
?>
<td width="43%" rowspan=2 align="center"><span style="padding: 10px 0px 0px 0px;">
    <input type="submit" id="submit" name="vote" value="Declare" />
  </span></td>
<?php }//if statement closing

?>
  <td valign="top" width="56%"><input type="radio" name="questions" value="<?php echo $question['id']; ?>" /><?php echo $question['question']; ?></td>
  </tr>
<?php

$x=$x+1;
}
?>
<tr>
<td valign="top" align="center" style="padding: 10px 0px 0px 0px;"><br /></td>
  <td width="1%">&nbsp;</td>
</tr>

<tr>
<td colspan="2" align="center" id="note">Please answer only once per person</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

config.php
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
<?php

//database settings
$hostname = 'localhost';
$username = 'root';
$password = '';
$dbname = 'poll1';

$connect = mysql_connect($hostname, $username, $password);
mysql_select_db($dbname); 

$query = mysql_query("SELECT * FROM poll ORDER BY id DESC LIMIT 1");
$rows = mysql_num_rows($query);

$poll = mysql_fetch_array($query);
$title = $poll['name'];

?>


Php-odbc Keeps Failing When I Try To Execute Select Statement!

Similar Tutorials View Content
I'm able to use PHP-ODBC to read the tables in an MDB file, as well as the column names on the tables. But when I try to read data from a particular table, it fails (I don't get an error, instead the browser pops up a message asking if I want to save the file "mdbtest.php" which is 0 bytes in size)! Any idea what's wrong?

Code: [Select]
//THIS WORKS
$conn = odbc_connect( 'TestDB', '', '' );
if ( !$conn) exit("Connection Failed: " . $conn);

//STILL FINE HERE
$sql = 'SELECT * FROM Customers';

//INCLUDING THIS LINE OF CODE CAUSES THE PROBLEM
$rs = odbc_exec( $conn, $sql );



Odbc Query Problem - Undefined Index

Similar Tutorials View Content
I have this code:
Code: [Select]
$sql = "SELECT adpat, adptnm, addate, adtime, adddsc, disdt, distm, drname, adptyp, ptprvtyp FROM hma711.zadpatnmf
JOIN hma711.addocrmf on adamdr = drno WHERE addate BETWEEN '20111115' AND '20111115' AND adpat BETWEEN '2000000' AND '2999999'";

$execute = odbc_exec($conn, $sql);

$num = odbc_num_rows($execute);
echo $num;

while($row = odbc_fetch_array($execute)){
    echo $row['adpat'];
}
It gets an error on this line: echo $row['adpat'];

The error is Notice: Undefined index: adpat in C:\xampp\htdocs\erboard\test.php on line 29

The query works directly on the AS400 I'm pulling from and the $num is being populated with the correct number of records.

This is the first time I have ever used php with odbc so I'm not sure what I'm missing. Any help would be greatly appreciated. Thanks!


Send A Web Table To An Excel Sheet Via Odbc And Sql

Similar Tutorials View Content
Hello to all

Here is the headache:

I want to make a website. In this website there is a table with multiple columns and rows. The cells of the table are editable by the user on the web. After filling the cells with numbers, the user clicks a button and the table is sent to an existing (but blank) excel spreadsheet.

I have the website and i am trying to understand the code beneath this. This is for my graduation paperwork and the schedule is very tight.

If you can teach me how to this I would be most grateful:

How to make a php script that transfers all the data in a table to an excel sheet? I am using ODBC connection and sql language like this one:

<?php
$ligacao=odbc_pconnect("test","","") or die ("error");
$sql="INSERT INTO [sheet$](F1) VALUES ('value1')";
$resultado=odbc_exec($ligacao,$sql);
echo $resultado;
odbc_close($ligacao);
?>

Thank you a lot!
 


How To Connect To A Database On A Live Server Using Odbc Command

Similar Tutorials View Content
Okay guys I have finished my db and I want to upload it to a live server but don't know exactly what to change in the code to get the ODBC_connect to open the path at the new server location please help.

my database  is located in a subfolder called Databases

i.e. "www.mydomain.com/Databases/myEvents.mdb"

what do i change in the connection string below to get it to open the file on the live server? Thanks in advance.


$conn = odbc_connect('myEvents','','');


Php Login Form With Odbc Connection Toms Access

Similar Tutorials View Content
So I'm doing a project and I need to make a successful login form, where it checks in MS Access if the username and password are correct, and if they are the user is taken to a new page. If they are wrong, a message comes up and they stay on the same page.

The user should first just see a blank form, but after submit is pressed, it should check if the username and password are correct. IF they are should be taken to a new page.

It's been a while since I used php last, so I wasn't quite sure how to tackle this issue. I was wondering if someone could please help me? here is my code.

Code: [Select]
<html>
<head>
<style type="text/css">



</style>
</head>
<body style="text-align:center">

<div id='title'>

</div>

<?php

print_r ($_POST) ;

if (isset($_POST['submit'])) { 

if(isset($_POST['username'])){
$username= $_POST['username'] ;
}
if(isset($_POST['password'])){
$TABLE= $_POST['password'] ;
}



$username  = null ;
$password  = null ;
 
$connection = odbc_connect('Olympics', '', '');
 
 
 if (!$connection)
{exit("Conection Failed: " . $connection);}


$username = stripslashes($username);
$password = stripslashes($password);

$sql = "select * from users where users = '$username' and passwords = '$password'";

$rs=odbc_exec($connection,$sql); 



$count=odbc_num_rows($rs);
 
if ($count == 1) {
     $_SESSION['loggedIn'] = "true";
     header("Location: searchpage.php");
} else {
     $_SESSION['loggedIn'] = "false";
    header("Location: index.php"); 
echo "Login failed" ;
}
 


}

echo "<form action='index.php' method='post'> \n" ;
echo" Please enter your username and password if you wish. <br/> \n" ;
echo "Username: <input type='text' name='username' > \n " ;
echo "Password: <input type='password' name='password' > \n" ;
echo "<input type='submit' value='Login' name='submit'> <br/> \n" ;
echo "<input type='submit' value='You may also continue you as a guest.'> \n" ;



?>
</body>
</html>


Query Empty When Trying To Insert Into Database (odbc Connection)

Similar Tutorials View Content
Hi, I hope you guys can help me out. I only know basic PHP and also SQL.  I haven't tried using connecting database yet.

My problem is that I'm trying to INSERT a data into an existing table using access but when it reaches $rs = odbc_exec(); it returns an error that the query was empty.

Here is the code:
Code: [Select]
$conn=odbc_connect('trial','','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql = "INSERT INTO Data (FirstName, LastName, BusinessName)
VALUES ('$fname', '$lname', '$bname')";

$rs=odbc_exec($sql, $conn);

$rs = @odbc_exec($conn,$sqlstring);

if (!$rs)
{
echo "An error has occured. Please try again", odbc_errormsg($conn);
}
else
{
echo "The record was successfully inserted.";
}

odbc_close($conn);

and here is the error:
Quote

An error has occured. Please try again[MySQL][ODBC 5.1 Driver][mysqld-5.5.20]Query was empty



I really hope you could help me out.

Thanks.


Help Needed Inserting Blobs Via Odbc In Oracle Database

Similar Tutorials View Content
Hey guys,

I`m having problems finding information on how to insert a image on a blob column trough odbc on a oracle database. Does anyone knows where can i find it, or can anyone help me with sample code? I really need to use odbc functions (cant use oci8 )

Tanks for your time reading this and for the possible input you may add on this.

Sincerely

Arestas


Php Login Form Verifying Username With Odbc Connect To Access

Similar Tutorials View Content
So basically my project is one where the user can log onto my website, and the page then checks if the ID and password are in my table in my microsoft access file.

If the username and password are the same, the user continues, if it isnt, then it stays on the same page and says something like "username and/or password are incorrect" or something along the lines of that.

the problem is right now im not sure how to make it say  "ERROR username and/or password is incorrect" if the username and password dont match. Can someone help me with this? and also make sure if the username and password are correct that it goes to the next page, entitled searchpage.php

here is the code Code: [Select]
<html>
<head>
<style type="text/css">



</style>
</head>
<body style="text-align:center">

<div id='title'>

</div>

<?php

print_r ($_POST) ;

if 

if (isset($_POST['Login'])) { 


if(isset($_POST['username'])){
$username= $_POST['username'] ;
}
if(isset($_POST['password'])){
$TABLE= $_POST['password'] ;
}



$username  = null ;
$password  = null ;
 
$connection = odbc_connect('Olympics', '', '');
 
 
 if (!$connection)
{exit("Conection Failed: " . $connection);}


$username = stripslashes($username);
$password = stripslashes($password);

$sql = "select * from users where users = '$username' and passwords = '$password'";

$rs=odbc_exec($connection,$sql); 



$count=odbc_num_rows($rs);
 
if ($count == 1) {
     $_SESSION['loggedIn'] = "true";
     header("Location: searchpage.php");
} else {
     $_SESSION['loggedIn'] = "false";
    header("Location: index.php"); 
echo "Login failed" ;
}
 


}

echo "<form action='index.php' method='post'> \n" ;
echo" Please enter your username and password if you wish. <br/> \n" ;
echo "Username: <input type='text' name='username' > \n " ;
echo "Password: <input type='password' name='password' > \n" ;
echo "<input type='submit' value='Login' name='Login'> <br/> \n" ;
echo "<input type='submit' value='You may also continue you as a guest.'> \n" ;
echo "</form>" ;



?>
</body>
</html>


Help On Connecting To Db

Similar Tutorials View Content
Hi there,

I'm working on a project already started, and using WAMP+WINDOWS7+SQL2008R2,

At this point it's connecting to a MSSQL DATABSE LIKE THIS:

$dns = "TempGes2";
$con = odbc_connect($dns, $user, $pwd);

This works fine, but i can't find where is the TempGes2 configured, it isn't in the odbcad32.exe,

Any ideas, i need to point this to another DATABASE,

Thank you in advance


Help With Connecting To Localhost

Similar Tutorials View Content
Hi, my school say not to use XAMPP, and I already have PHP installed, MySQL installed, Apache I am not sure, but assuming if I have it installed, how do I connect to localhost b/c beforer when I use XAMPP, the default for where to get php/mysql running was: C:\xampp\htdocs\

Please any help appreciated!


Connecting Mysql With Php

Similar Tutorials View Content
So I'm currently watching this tutorial : http://youtu.be/9E0s4gsUeU0
And am trying to build the sample application shown there. However I do seem to run into some problems, so if someone could take the time to help me out; I would be very grateful!

---
The application is a simple HTML form, which takes the data input and stores it into a MySQL database table.

My project is organized as this :


The actual form is stored on the insert.php file.
Code: [Select]
<?php

include_once('resources/init.php');

if (isset($_POST['title'], $_POST['post'])) {

// functions go here!

}


?>

<html>
<head>
<title>
Post something!
</title>
</head>

<body>

<div id="form">
<form method="POST" action= " ">
<label for="title">Title:</label><br>
<input type="text" name="title" id="title" /><br>
<label for="post">Post:</label><br>
<textarea name="post" id="post" rows="15" cols="50"></textarea><br>

</form>
</div>

</body>
</html>


The config.php and init.php are the configuration and initialize files.

config.php
Code: [Select]
<?php

 $config['DB_HOST'] = 'localhost';
 $config['DB_USER'] = 'root';
 $config['DB_PASS'] = '';
 $config['DB_NAME'] = 'form';
 
//foreach ( $config as $k => $v ) {
//  define(strtouper($k), $v);
//}

?>


init.php
Code: [Select]
<?php

 include_once('config.php');
 
 mysql_connect(DB_HOST, DB_USER, DB_PASS);
 mysql_select_db(DB_NAME);
 
?>
---

When I try this in my browser I get the error :
Code: [Select]
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'DB_HOST' (11004) in C:\xampp\htdocs\form\resources\init.php on line 5

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\form\resources\init.php on line 6

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\xampp\htdocs\form\resources\init.php on line 6

Could someone tell me what is wrong?

Thanks in advance!







Php Is Not Connecting To Mysql Database?

Similar Tutorials View Content
For some reason Im not able to connect to mysql database, when i fill in the form and select search, it just basically refreshes the page but does not come up with no error messages or any results from my database. any help is appreciated.

HTML Code

Code: [Select]

<table id="tb1">
<tr>
<td><p class="LOC">Location:</p></td>
<td><div id="LC">
<form action="insert.php" method="post">
<select multiple="multiple" size="5" style="width: 150px;" >
<option>Armley</option>
<option>Chapel Allerton</option>
<option>Harehills</option>
<option>Headingley</option>
<option>Hyde Park</option>
<option>Moortown</option>
<option>Roundhay</option>
</select>
</form>
</div>
</td>

<td><p class="PT">Property type:</p></td>
<td><div id="PS">
<form action="insert.php" method="post">
<select name="property type" style="width: 170px;">
<option value="none" selected="selected">Any</option>
<option value="Houses">Houses</option>
<option value="Flats / Apartments">Flats / Apartments</option>
</select>
</form>
</div>
</td><td>
<div id="ptype">
<form action="insert.php" method="post">
<input type="radio" class="styled" name="ptype" value="forsale"/> For Sale

<p class="increase">
<input type="radio" class="styled" name="ptype" value="forrent"/> To Rent
</p>
<p class="increase">
<input type="radio" class="styled" name="ptype" value="any"/> Any
</p>
</form>
</div>
</td>
</tr>

</table>

<div id="table2">
<table id="NBtable">
<tr>
<td><p class="NBS">Number of bedrooms:</p></td>
<td><div id="NB">
<form action="insert.php" method="post">
<select name="number of bedrooms">
<option value="none" selected="selected">No Min</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select> to

<select name="number of bedrooms">
<option value="none" selected="selected">No Max</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</form>
</div>
</td>

<td><p class="PR">Price range:</p></td>
<td><div id="PR">
<form action="insert.php" method="post">
<select name="price range">
<option value="none" selected="selected">No Min</option>
<option value="50,000">50,000</option>
<option value="60,000">60,000</option>
<option value="70,000">70,000</option>
<option value="80,000">80,000</option>
<option value="90,000">90,000</option>
<option value="100,000">100,000</option>
<option value="110,000">110,000</option>
<option value="120,000">120,000</option>
<option value="130,000">130,000</option>
<option value="140,000">140,000</option>
<option value="150,000">150,000</option>
<option value="160,000">160,000</option>
<option value="170,000">170,000</option>
<option value="180,000">180,000</option>
<option value="190,000">190,000</option>
<option value="200,000">200,000</option>
<option value="210,000">210,000</option>
<option value="220,000">220,000</option>
<option value="230,000">230,000</option>
<option value="240,000">240,000</option>
<option value="250,000">250,000</option>
<option value="260,000">260,000</option>
<option value="270,000">270,000</option>
<option value="280,000">280,000</option>
<option value="290,000">290,000</option>
<option value="300,000">300,000</option>
<option value="310,000">310,000</option>
<option value="320,000">320,000</option>
<option value="330,000">330,000</option>
<option value="340,000">340,000</option>
<option value="350,000">350,000</option>
</select> to

<select name="price range">
<option value="none" selected="selected">No Max</option>
<option value="50,000">50,000</option>
<option value="60,000">60,000</option>
<option value="70,000">70,000</option>
<option value="80,000">80,000</option>
<option value="90,000">90,000</option>
<option value="100,000">100,000</option>
<option value="110,000">110,000</option>
<option value="120,000">120,000</option>
<option value="130,000">130,000</option>
<option value="140,000">140,000</option>
<option value="150,000">150,000</option>
<option value="160,000">160,000</option>
<option value="170,000">170,000</option>
<option value="180,000">180,000</option>
<option value="190,000">190,000</option>
<option value="200,000">200,000</option>
<option value="210,000">210,000</option>
<option value="220,000">220,000</option>
<option value="230,000">230,000</option>
<option value="240,000">240,000</option>
<option value="250,000">250,000</option>
<option value="260,000">260,000</option>
<option value="270,000">270,000</option>
<option value="280,000">280,000</option>
<option value="290,000">290,000</option>
<option value="300,000">300,000</option>
<option value="310,000">310,000</option>
<option value="320,000">320,000</option>
<option value="330,000">330,000</option>
<option value="340,000">340,000</option>
<option value="350,000">350,000</option>

</select>
</form>
</div>
</td>


</tr>

</table>

PHP Code
Code: [Select]

<?php
$server = "";      // Enter your MYSQL server name/address between quotes
$username = "";    // Your MYSQL username between quotes
$password = "";    // Your MYSQL password between quotes
$database = "";    // Your MYSQL database between quotes

$con = mysql_connect($server, $username, $password);       // Connect to the database
if(!$con) { die('Could not connect: ' . mysql_error()); }  // If connection failed, stop and display error

mysql_select_db($database, $con);  // Select database to use

$result = mysql_query("SELECT * FROM tablename");  // Query database

while($row = mysql_fetch_array($result)) {     // Loop through results
  echo "<b>" . $row['id'] . "</b><br>\n";      // Where 'id' is the column/field title in the database
  echo $row['location'] . "<br>\n";            // Where 'location' is the column/field title in the database
  echo $row['property_type'] . "<br>\n";       // as above
  echo $row['number_of_bedrooms'] . "<br>\n";  // ..
  echo $row['purchase_type'] . "<br>\n";       // ..
  echo $row['price_range'] . "<br>\n";         // ..
}

mysql_close($con);  // Close the connection to the database after results, not before.
?>

To connect to my database I an entering mysql database details just at the first top lines server,username,password and database. is thats correct?

Thank You for your help in adavance.


Problems Connecting To Database.

Similar Tutorials View Content
Hi.

For a uni assignment I am turning my static prototype into a dynamic prototype and adding various features like templates, log in system and the ability to add/delete information stored on the database and view the information on the website.

I have running into a problem though, I am having difficulties getting connected to the database, I don't know if this is something to do with the log in information though, below I have quoted the files.

update.php (the script I use to connect to the database)
Quote

<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$name = $_POST['name'];
$sname = $_POST['sname'];
$address = $_POST['address'];
$number = $_POST['number'];

mysql_connect("localhost", "", "") or die ('error:   ' .mysql_error());
mysql_select_db ("bza410_test");

$query="INSERT INTO testTable (id, firstname, surname, address, phone)VALUES ('NULL','".$name."', '".$sname."', '".$address."', '".$number."')";

mysql_query($query) or die ('error updating database');

echo "database updated with: " .$name. " ".$sname."  ".$address." ".$number ;


?>
 


after localhost I am aware password/username goes there, just removed them for obvious reasons.

home.php
Quote

<?php
$pagetitle = 'Welcome to ENSI';
require 'template/header.php';
?>
<p> This web page page was created on <strong>
                <?php
                echo date('l F jS \a\t Y h:i:s A \,');
                if (date('H') < 12) {
                    echo ' RISE AND SHINE!!!,';
                } else {
                    echo ' TIME TO SLEEP!!!,';
                }
                ?>
            </strong> on the computer that is running on PHP. </p>

            <div>
            <p><strong>Please enter your name and birthday:-</strong></p>
           <form method="post" action="update.php">
                <fieldset>
                    <legend>Details</legend>
                    <label>First Name:</label>
                    <input type="text" name="name" />
                    <br/>
                    <label> Surname:</label>
                    <input type="text" name="sname" />
                    <br/>
                    <label> Address </label>
                    <input type="text" name="address" />
                    <br/>
                    <label>Phone</label>
                    <input type="text" name="number" />
                    <br/>
                   <input type="submit" name="submit" value="submit" />
                    <input type="reset" name="reset" value="reset" />
                </fieldset>
            </form>
            <?php
            if(isset ($_POST['submit'])) {

            $name = $_POST['name'];
            $sname = $_POST['sname'];
            $address = $_POST['address'];
            $number = $_POST['number'];
            echo htmlentities ($text);
            echo 'Hello, your first name is ' .$name;
            echo ' Your surname is ' .$sname;
            echo ' Your address is - ' .$address;
            echo ', Your phone number is - ' .$number;
            }
            ?>
        </div>
<?php
require 'template/footer.php';
?>



When I fill in the form and then press submit it goes to "error updating database" from the script, so have I got the server information wrong?


Thanks
   Will.


Privacy