PHP - Does Php Supports Read/write From Linked Tables In Ms-access
HI,
I have a ms-access file which has linked table. The linked table is connected to a ODBC source (e.g MS-SQL or 3rd Party ODBC Driver). WebPage(php) Apache, connecting to a ODBC DSN of MS-Access, MS-Access is having linked tables. Linked tables as from another ODBC source. On the PHP Page, When I am trying to connect the ms-access odbc dsn , I am able to connect. But when I query any of the linked tables, PHP is not able to query and is failing. Does php has capabilities to read/write to linked tables in ms-access file. Or it is issue with MS-Access Or is it I am missing something. Microsoft says, its an issue of PHP https://social.msdn....forum=accessdev Requesting you to please share your feedback Regards Rajendra Dewani Similar TutorialsSo I have 3 tables, student, student_course and course. I'm only using student and course atm, probably should look into student_course haha well those are the tables provided to us for the project I'm working on. I'm trying to list all the courses from the course table and then when clicking on a course I want to display all the students who registered for this course( which would probably be the student table) Here is my code for displaying the courses: Code: [Select] <?php $display_sql ="SELECT cname FROM course ORDER BY cid DESC"; $display_query = mysql_query($display_sql) or die(mysql_error()); $rsDisplay = mysql_fetch_assoc($display_query); ?> <html> <head> </head> <body> <p> Click course to display all students registered for that course</p> <?php do { ?> <p><a href="test.php?cname=<?php echo $rsDisplay['cid']; ?>"> Course: <?php echo $rsDisplay['cname']; ?> </a> </p> <?php } while ($rsDisplay = mysql_fetch_assoc($display_query)) ?> And here is my code for displaying the students from the student table registered for the specific course you click on: Code: [Select] <?php $q = "SELECT * FROM student WHERE cname = $_GET[cname]"; $confirm_query = mysql_query($q); $rsconfirm = mysql_fetch_assoc($confirm_query); ?> <html> <head> </head> <body> <p> Displaying all student </p> <p> First Name <?php echo $rsconfirm['sname']; ?> </p> <p> Surname: <?php echo $rsconfirm['fname']; ?> </p> I'm very new to php. Im using "test.php?cname=" to transfer the cname (course name) info from my course table to the next page where I use $_GET[cname]";. cname isn't a primary key in my table, rather just a row. Can it be done like that? Or should you just use primary keys? I managed to display the courses but when clicking it, it wont display the registered users and gives me an error: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.3\www\Project\test.php on line 28 What does that mean? Line 28 is this part : Code: [Select] $q = "SELECT * FROM student WHERE cname = $_GET[cname]"; //26 $confirm_query = mysql_query($q); //27 $rsconfirm = mysql_fetch_assoc($confirm_query); //28 Any criticism welcome. When coding I'm still trying to figure out what it is I'm doing nevermind getting it to work haha. Thanks in advance Im doing a search system and Im having some problems.
I need to search in two tables (news and pages), I already had sucess doing my search system for just one table, but for two tables its not easy to do.
I already use a select statment with two tables using UNION because I want to show number of search results, that is number of returned rows of my first sql statment.
But now I need to do a select statment that allows me to acess all fields of my news table and all fields of my pages table.
I need to acess in my news table this fields: id, title, content, link, date, nViews
I need to acess in my pages table this fields: id, title, content, link
Im trying to do this also with UNION, but in this case Im not having any row returning.
Do you see what I have wrong in my code?
<?php //first I get my $search keyword $search = $url[1]; $pdo = connecting(); //then I want to show number of returned rows for keyword searched $readALL = $pdo->prepare("SELECT title,content FROM news WHERE title LIKE ? OR content LIKE ? UNION SELECT title,content FROM pages WHERE title LIKE ? OR content like ?"); $readALL->bindValue(1,"%$search%", PDO::PARAM_STR); $readALL->bindValue(2,"%$search%", PDO::PARAM_STR); $readALL->bindValue(3,"%$search%", PDO::PARAM_STR); $readALL->bindValue(4,"%$search%", PDO::PARAM_STR); $readALL->execute(); //I show number of returned rows echo '<p>Your search keyword returned <strong>'.$readALL->rowCount().'</strong> results!</p>'; //If dont return any rows I show a error message if($readALL->rowCount() <=0){ echo 'Sorry but we didnt found any result for your keyword search.'; } else{ //If return rows I want to show, if it is a page result I want to show title and link that I have in my page table //if it is a news result I want to show title and link that I have in my news table and also date of news echo '<ul class="searchlist">'; $readALL2 = $pdo->prepare("SELECT * FROM news WHERE status = ? AND title LIKE ? OR content LIKE ? LIMIT 0,4 UNION SELECT * FROM pages where title LIKE ? OR content LIKE ? LIMIT 0,4"); $readALL2->bindValue(1, '1'); $readALL2->bindValue(2, "%$search%", PDO::PARAM_STR); $readALL2->bindValue(3, "%$search%", PDO::PARAM_STR); $readALL2->bindValue(4, "%$search%", PDO::PARAM_STR); $readALL2->execute(); while ($result = $readALL2->fetch(PDO::FETCH_ASSOC)){ echo '<li>'; echo '<img src="'.BASE.'/uploads/news/'.$result['thumb'].'"/>'; echo '<a href="'.BASE.'/news/'.$result['id_news'].'">'.$result['title'].'</a>'; //if it is a news result I also want to show date on my list //echo '<span id="date">'.$result['date'].'</span>'; echo '</li>'; } echo ' </ul>'; //but how can I do my select statement to have access to my news table fields and my page table fields?? } ?> I am trying to write some data from multiple SQL tables to a page. In the first table is a list of places. I then have more tables that are named after the different places. For example, say my first place in the list is called Place1. I have a table named Place1 with data that corresponds to place1. The data contained in the table named Place1 is a list of things to do in this place. It has 21 columns and each one is something to do in the morning, afternoon, and at night for each day of the week in the place Place1. What I am trying to do is display a sort of weekly calendar as a table on a webpage that lists all of the places in one column and then lists seven days of the week as 7 more columns. Then in each data cell I would want to list the things to do in the morning, afternoon and at night for the certain day of the week and for the place. The problem is that I am creating a CMS to allow other users with no coding knowledge to update events for other places, so I have to display data that could have been altered. The only solution I know of is to do a while loop that gets all of the place names and while there are still place names, write the place names to the page and set a variable equal to the place name. Inside the while loop I would create another while loop that each time the first while loop is executed uses the variable set in the first while loop to know which table to reference and then make a call to that table pulling out the 21 columns and writing them to the page. Each time the outer while loop executes, it would (hopefully) write the place name, and then set the variable as the current place name so that the inner while loop uses the variable to write the rest of the information about that place. I don't know if that would even work and if it did, I know it cannot be the best way to do this. I am pretty stuck here and don't really have a good solution so if anyone proposes a solution that is radically different to anything I have done, I am open to everything. Thank you! Hey guys, any suggestions how i could read and write msWord files without using the COM interface. I need to keep all the formatting intact though... any ideas? many thanks hgey guys im trying to create a text based login but im having trouble to get the echo to show up on submit.php which is the form action page for signup.html. am not sure how i would make it showup on either file. <?php $myFile = "password.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $data= strip_tags($_POST['Username']); fwrite($fh,$data); fclose($fh); $File = "username.txt"; $fh2 = fopen($File, 'w') or die("can't open file"); $mydata = strip_tags($_POST['Password']); fwrite($fh2,$data); fclose($fh2); echo "You have Signed up Successfully Congrats!"; ?> I very new to php and all I am simply trying to do is read the contents of a text file and echo it out on the screen. I have tried many things to see what I am doing wrong but it just simply isnt working for me. I know the server I am using has php enabled as well because I have tried a simple echo and it works fine. This is the code I am currently using. <?php $file = fopen(file.txt", 'r'); $read = fread($file, '6') echo $read; ?> also, I have tried this. <?php $file = file_get_contents('file.txt'); echo $file; ?> I have a file.txt on the server I am using in the same directory as index.php, I feel like this should be working but I get no result! Alls I have in the text file is a statement that says "hello world". Hi, I want to read image file and write in to word document file using php. Actually i am developing shopping cart site. for that i have created barcode image. i need to take print outs. for example if i click print means same barcode should be generate 64 times in word document. how i do it? i have tried with COM. please check the following code <?php // starting word $word = new COM("word.application") or die("Unable to instantiate Word"); echo "Loaded Word, version {$word->Version}\n"; //bring it to front $word->Visible = 1; //open an empty document $word->Documents->Add(); //do some weird stuff for($i=1;$i<=64;$i++) { $word->Selection->InlineShapes->AddPicture("D:\Program Files\wamp\www\b.jpg ",false, True); } $word->Documents[1]->SaveAs("D:\Program Files\wamp\www\Uselesstest.doc"); //closing word $word->Quit(); //free the object $word = null; ?> It works fine in local. but it is not working in server (it says COM.class is missing). i have checked some forums they said it works with MS based operation system. i have checked with windows only. Please kindly any one help me asap the way for read and write image file in word document. can we do this any other way? we are reading and writing txt files using php the same can we do with image file (read and write in word document) ?? Thanks Prema Hi, I've been googling for a while now for an example of how to read, edit and write a configuration file. This part was easy to find... <?php $icon_settings = parse_ini_file("test.desktop"); print_r($icon_settings); ?> ...the above code works great, but how do I edit and write back a configuration file like this... Code: [Select] #!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Name=Firefox Web Browser Comment=Browse the World Wide Web GenericName=Web Browser Exec=firefox %u Terminal=false X-MultipleArgs=false Type=Application Icon=firefox # ... and so on back to the drive? Thanks. I have a MySQL database with each record of a person who has registered for an event, I am displaying the information on a web page for a user, but he wants to be able to print out all the records in alphabetical order by last name, first name later on so he will have a hard copy of each person who has registered at the table when they arrive. How can I write each record to a Txt file that he can print out later that will be formated with the record contents along with each fields definition (Ex. Last Name - Smith, First Name - John, etc)? Hey all, I am in a situation where database management system needs to be up and running very quickly, which would store records of addresses possibly from all the properties in a particular US state. But it would only be 1 US state, not all. These records need to be updated and retrieved for particular campaigns. The programming solution (e.g. PHP) would need to be able to import csv files generated from excel and match the records in the database in order to know which fields to update. It seems like a lot of work to do this from scratch using PHP in the short-term, given time limitations. Hence, I was considering using Microsoft Access as a front end in the interim and then when time is available writing a web-based PHP/MySql application using HTML, CSS, and JavaScript front end to allow users to easily perform data entry. Does anyone think this is a smart course of action? Ideally a web PHP app would be more robust, but considering it needs to be done from scratch, it would be time consuming. There's no right or wrong answer for this. I'm just looking for opinions. Thanks for any response. Hi All, I am using PHP 5.3 and storing php session data to the database using session.set_save_handler callbacks. I see that the write method, strangely treats the Class constant as undefined. All the other methods seem to work fine with the class constant. Any reason why this would happen? Please see code below. I get an error "Use of undefined constant db_table in Sessions.php in line". This seems to be happening only with the write api. Can someone please help? Thanks class Sessions { //var $life_time; var $id; var $data; const db_table = 'php_mysql_session'; function PHPSessions() { // Read the maxlifetime setting from PHP //$this->life_time = get_cfg_var("session.gc_maxlifetime"); $this->id = session_id(); $this->data = ''; // Register this object as the session handler session_set_save_handler( array( &$this, "_open" ), array( &$this, "_close" ), array( &$this, "_read" ), array( &$this, "_write" ), array( &$this, "_destroy") , array( &$this, "_gc" ) ); } function _open () // open the session. { Zend_Log::log("opening connection"); global $_sess_db; Zend_Log::log("session db ".$_sess_db); if ($_sess_db = mysql_connect(DB_HOST_READ, DB_USER, DB_PASS)) { return mysql_select_db('TEST_SESSION', $_sess_db); } // If there is a failure return false return FALSE; } // open function _close () // close the db connection here { global $_sess_db; return mysql_close($_sess_db); } // close function _read ($id) // read any data for this session. { global $_sess_db; Zend_Log::log("Session db ".$_sess_db); //$id = mysql_real_escape_string(session_id()); Zend_Log::log("Session Id :" .$id); $sql = "SELECT * FROM ". self::db_table ." WHERE session_id = '$id'"; Zend_Log::log("SQL IS : ".$sql); $data = ''; $result = mysql_query($sql); $a = mysql_num_rows($result); Zend_Log::log("Record count ".$a); if($a > 0) { Zend_Log::log("Record Exists!"); $row = mysql_fetch_assoc($result); $data = $row['session_data']; Zend_Log::log("Fetching session Data ".$data); return $data; } else { Zend_Log::log("No Data ".$data); return ''; } } function _write ($id, $data) // write session data to the database. { global $_sess_db; $newid = mysql_real_escape_string($id); $newdata = mysql_real_escape_string($data); $sql = "REPLACE ". self::db_table ." (session_id,user_id,session_data,date_created) VALUES('$newid', '$userid', '$newdata', 'NOW()')"; $rs = mysql_query($sql); return TRUE; } // write function _destroy ($id) // destroy the specified session. { Zend_Log::log("Destroy method "); return TRUE; } // destroy function _gc ($max_lifetime) // perform garbage collection. { Zend_Log::log("GC Method"); return TRUE; } // gc function _destruct () // ensure session data is written out before classes are destroyed // (see http://bugs.php.net/bug.php?id=33772 for details) { @session_write_close(); } // __destruct // **************************************************************************** } // end class I need help connecting to a Visual FoxPro 9 Database and Table via php. I know this is possible because I've read of people doing this but I still have no resolve on this issue. Does anyone know of anyway to connect to a VFP9 table via php? I would like step by step instructions on how to handle this including any server dependencies or installations needed to make this work. (Server: Linux, webserver, Apache, PHP) (Visual Foxpro Database is in another location in a windows machine.) To access MySql tables from PHP, I use the PHP code and the function below. If I make these changes, would this code work for SQL Server 2008? mysql_fetch_array to mssql_fetch_array mysql_connect to mssql_connect mysql_select_db to mssql_select_db mysql_query to mssql_query PHP code -------------------------------------------------------------------------------- $sql = "SELECT mast_id FROM district_mast WHERE mast_district = '".$dist_num."'"; $result = func_table_access($sql); $rows = mysql_fetch_array($result); Function -------------------------------------------------------------------------------- FUNCTION func_table_access($sql) { $db = "aplustutoru"; $host = "localhost"; $user = "root"; $pass = ""; IF (!($conn=mysql_connect($host, $user, $pass))) { PRINTF("error connecting to DB by user = $user and pwd=$pass"); EXIT; } $db3 = MYSQL_SELECT_DB($db,$conn) or die("Unable to connect to local database"); IF ($sql <> "justopendb") { $result = MYSQL_QUERY($sql) OR DIE ("Can not run query because ". MYSQL_ERROR()); RETURN $result; } } Hi again, i'm wondering how can i make Sort (for example a-z) an column in php reading mysql informations. Here's the script: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="table.css" type="text/css"> </head> <body style="margin: 0 0 0 0;"> <? include("passwd.php"); @$start = $_GET["start"]; if($start =='') $start =0; include("lib.php"); $link = mysql_connect($host,$username,$password); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($db, $link); if (!$db_selected) { die ("Can't use $db : " . mysql_error()); } //total number of records in the table $res = mysql_query("SELECT * from `$table`"); @$rows = mysql_num_rows ($res); $result = mysql_query("SELECT * from `$table` limit $start,10"); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "<p align=center class = 'menu'> Ocitana tabela: $table </p>"; $cols = mysql_num_fields($result); $records = mysql_num_rows ($result); echo "<table align='center' width='1200' >"; echo "<tr bgcolor='BBCCDD' class='menu'>"; for ($i = 0; $i < $cols;$i++) { echo "<td align='center'>".mysql_field_name($result,$i)."</td>"; } echo "</tr>"; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<tr bgcolor='F6F6F6' class='normal'>"; foreach ($row as $value) { echo "<td align='center'>".$value ."</td>"; } echo "</tr>"; } $end = $start + $records; echo "<tr align = 'center' bgcolor = 'BBCCDD' class='menu'><td colspan=$cols> Prijema $start do $end od $rows </td></tr>"; echo "<tr align = 'center' class='mylink'><td colspan=$cols> "; if($start != 0) { $prev = $start - 10; echo "<a href='tabela.php?start=$prev'> Prethodna </a> "; } if($start<$rows-10) { $next = $start + 10; echo "<a href = 'tabela.php?start=$next'>Sledeca</a> "; } echo "</td></tr>"; echo "</table>"; ?> </body> </html> First, I read PHP does not support function overloading. Then later in the book in chapter of OOP, it states: PHP supports function overloading, which means that you can provide more than one function with the same name and different numbers or types of parameters. So does it support function overloading or not? And of course my definition of function overloading is what you get in the Java programming language. Hello,
I try to get website speed of some website, but i can read only ''domain.com'' i can't read website files like css , js ... why ? i use proxies for this job.
here is the php code:
$options = array( 'useragent' => "Firefox (+http://www.firefox.org)", // who am i 'connecttimeout' => 120, // timeout on connect 'timeout' => 120, // timeout on response 'redirect' => 10, // stop after 10 redirects 'referer' => "http://www.google.com", 'proxyhost' =>'85.25.8.14:80' ); $response = http_get("http://solve-ict.com/wp-content/themes/ict%20theme/js/jquery-1.7.1.min.js", $options , $info);but it works fine with http://domain.com/ , but with files css or js it gives 404, using some free proxy servers available ? Thanks. Trying to get this done: Page_1 has many external links, when certain links are clicked i do not want user to go directly to page, but rather go to a special add page_2 where user must click a second time on the link to finally get there. The add page_2 must show on screen the name of the initial link from page_1, it must change accordingly with the link it came from page_1,once on page_2 the hyperlink redirects outside the site. So far i am thinking give an id to the div or "<a href..." on page_1 then somehow have page_2 detect that id and fill in the variable for the final external link. Other wise is there a way to detect a url from incoming? I guess a similar example is how some domain name sellers landing page will indicate the name of the site. Such as "Thisdomain.com" is for sale. same landing page but the name changes according to the domain that was typed. I got a question im using izabi for me im one who loves the software. But there some quirks that they forgot to add when making the mail system. I was wondering how it would be possible to code in a peice of php where it says read after someone read the email. If you need a copy of the mail mail script let me know. Hi all, first time posting here and wondering if anyone can help me. Ive linked a button in a HTML so that it sends an email to me. But the thing thats really bugging me is that sometimes it sends the persons email address and sometimes it doesnt AND ALSO ive got multiple boxes in my HTML that I want it to send but it will only send 1 and not all 5. This is what my PHP looks like at the moment: <?php $email = $_REQUEST[ 'email_box' ] ; $message = $_REQUEST[ 'test1_box' ] ; $message = $_REQUEST[ 'test2_box' ] ; $message = $_REQUEST[ 'test3_box' ] ; $message = $_REQUEST[ 'test4_box' ] ; $message = $_REQUEST[ 'test5_box' ] ; mail( "test1049@live.com", "Test Feedback sheet", $message, "From: $email" ); ?> Can you please tell me where I have gone wrong? I really need this to be sorted out and im completely new to PHP, ive only just gotten past basic knowledge of html |