Jump to content

Newbie89

Members
  • Posts

    58
  • Joined

  • Last visited

Posts posted by Newbie89

  1. and also this: <?php$random = rand(1,3);$dbHandle = new PDO("sqlite:/var/databases/testsite/database.sqlite");$result = $dbHandle->query("SELECT * FROM mybooks WHERE id=$random");$book = $result->fetch(PDO::FETCH_ASSOC);echo "Random peek into my libary:<br><br>$book[title] by $book[author]";?>

  2. Example such like as shown at the bottom: <?php$dbHandle = new PDO("sqlite:/var/databases/testsite/database.sqlite");$dbHandle->exec("CREATE TABLE mybooks (id INTEGER PRIMARY KEY, author NOT NULL, title NOT NULL)");$mybooks = array( "Mass Effect: Revelation" => "Drew Karpyshyn", "Mass Effect: Ascension" => "Drew Karpyshyn", "Dragon Age: The Stolen Throne" => "David Gaider");while (list($title,$author) = each($mybooks)) { $author = $dbHandle->quote($author); $title = $dbHandle->quote($title); $result = $dbHandle->exec("INSERT INTO mybooks (author,title) VALUES ($author,$title)");}?>

  3. Here is the code... 1 #include <stdio.h> 2 #include <sqlite3.h> 3 4 int main(void) { 5 sqlite3 *conn; 6 sqlite3_stmt *res; 7 int error = 0; 8 int rec_count = 0; 9 const char *errMSG; 10 const char *tail; 11 12 error = sqlite3_open("ljdata.sl3", &conn); 13 if (error) { 14 puts("Can not open database"); 15 exit(0); 16 } 17 18 error = sqlite3_exec(conn, 19 "update people set phonenumber=\'5055559999\' where id=3", 20 0, 0, 0); 21 22 error = sqlite3_prepare_v2(conn, 23 "select lastname,firstname,phonenumber,id from people order by id", 24 1000, &res, &tail); 25 26 if (error != SQLITE_OK) { 27 puts("We did not get any data!"); 28 exit(0); 29 } 30 31 puts("=========================="); 32 33 while (sqlite3_step(res) == SQLITE_ROW) { 34 printf("%s|", sqlite3_column_text(res, 0)); 35 printf("%s|", sqlite3_column_text(res, 1)); 36 printf("%s|", sqlite3_column_text(res, 2)); 37 printf("%u\n", sqlite3_column_int(res, 3)); 38 39 rec_count++; 40 } 41 42 puts("=========================="); 43 printf("We received %d records.\n", rec_count); 44 45 sqlite3_finalize(res); 46 47 sqlite3_close(conn); 48 49 return 0; 50 }

  4. <!DOCTYPE html><html><head><script>function loadXMLDoc(){var xmlhttp;if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","ajax_info.txt",true);xmlhttp.send();}</script></head><body> <div id="myDiv"><h2>Let AJAX change this text</h2></div><button type="button" onclick="loadXMLDoc()">Change Content</button> </body></html>

  5. I got the error when click the textbox of time in order.html.Error show like this... <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /checksite/serverTime.php was not found on this server.</p><hr><address>Apache/2.2.22 (Ubuntu) Server at localhost Port 80</address></body></html>

  6. order.html <html><body> <script language="javascript" type="text/javascript"><!-- //Browser Support Codefunction ajaxFunction(){var ajaxRequest; // The variable that makes Ajax possible! try{// Opera 8.0+, Firefox, SafariajaxRequest = new XMLHttpRequest();} catch (e){// Internet Explorer Browserstry{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){// Something went wrongalert("Your browser broke!");return false;}}}// Create a function that will receive data sent from the serverajaxRequest.onreadystatechange = function(){if(ajaxRequest.readyState == 4){document.myForm.time.value = ajaxRequest.responseText;}}ajaxRequest.open("GET", "serverTime.php", true);ajaxRequest.send(null); } //--></script> <form name='myForm'>Name: <input type='text' onChange="ajaxFunction();" name='username' /> <br />Time: <input type='text' name='time' /></form></body></html>

×
×
  • Create New...