PHP - Javascript Json.parse Not Working, Halts All Code Afterwards From Working....
http://paste.ee/p/OhiWv
The above is a link to a readable version of my code. The XMLHTTPREQUEST worked, and the array was pulled down. Was able to print out the undecoded/unparsed array. However, immediately afterwards, all code stops working.
<script> var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 8 and older xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(); xhr.onreadystatechange = display_data; var $phparray function display_data() { if (xhr.readyState == 4) { if (xhr.status == 200) { //alert(xhr.responseText); $phparray = xhr.responseText; document.getElementById("suggestion").innerHTML = $phparray; // // //......................................................? // The above line of code is the last thing to print or // to do anything that returns to the browser.... //.......................................................? // All lines below do nothing............................? // } else { //alert('There was a problem with the request.'); } } } document.write("Length of phparray Array :" + $phparray.length + "<"); var output = JSON.parse($phparray, function (key,val) { if ( typeof val === 'string' ) { // regular expression to remove extra white space if ( val.indexOf('\n') !== -1 ) { var re = /\s\s+/g; return val.replace(re, ' '); } else { return val; } } return val; } ); document.write("Length of Array :" + $output.length + "<"); for (var i=0; i < $output.length; i++) { document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME; } </script> Similar Tutorialscan any body tell me why im not getting the value of the profile id $json = '{\"profile_id\":100000503667042,\"sk\":\"info\"}'; $obj = (json_decode($json)); print $obj->{'profile_id'}; i dont understand what is wrong plz help me.
here is code
$name = "img/".rand(1,9999999).".png"; $myFile = $name; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $html; fwrite($fh, $stringData); fclose($fh); $file=$name; $fst=file_get_contents($file); $im=imagecreatefromstring($fst); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_NEGATE); //Convert to Grey Scale for($i=0;$i<123;$i++){ for($j=0;$j<50;$j++){ $px=imagecolorat($im,$i,$j); if($px<0x303030){ imagesetpixel($im,$i,$j,0); }else{ imagesetpixel($im,$i,$j,0xffffff); } } } $database = unserialize(@file_get_contents("db.txt")); if($database === false) $database = array(); // modify the database if needed if($_SERVER['REQUEST_METHOD'] == 'POST'){ if($_POST['submit'] == 'Add') $database[$_POST['ident']] = substr($_POST['letter'], 0, 1); if($_POST['submit'] == 'Del') unset($database[$_POST['ident']]); if($fh = @fopen('db111.txt', 'w+')){ fwrite($fh, serialize($database)); fclose($fh); } }else{ $newimage = true; } $width = 130; $height = 40; $captcha_gridstart =1; $captcha_gridspace =2; $letters = findletters($im, $width, $height, $captcha_gridstart, $captcha_gridspace); $count = count($letters); $cellw = ($count > 0) ? intval(100 / $count) : 0; //dispeckle the image and GET co-ordinates of the characters of captcha image and return them. function findletters($image, $width, $height, $gridstart, $gridspace){ $offsets = array(); $o = 0; $atstartx = true; for($x = 0; $x < $width; $x++){ $blankx = true; for($y = 0; $y < $height; $y++){ if(imagecolorat($image, $x, $y) == 0){ $blankx = false; break; } } if(!$blankx && $atstartx){ $offsets[$o]['startx'] = $x; $atstartx = !$atstartx; }else if($blankx && !$atstartx){ $offsets[$o]['endx'] = $x; $atstartx = !$atstartx; $o++; } } $count = $o; for($o = 0; $o < $count; $o++){ for($y = 0; $y < $height; $y++){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['starty'] = $y; break; } } for($y = $height-1; $y > $offsets[$o]['starty']; $y--){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['endy'] = $y; break; } } } for($o = 0; $o < $count; $o++){ $offsets[$o]['ident'] = ""; for($x = $offsets[$o]['startx'] + $gridstart; $x < $offsets[$o]['endx']; $x += $gridspace){ for($y = $offsets[$o]['starty'] + $gridstart; $y < $offsets[$o]['endy']; $y += $gridspace){ $offsets[$o]['ident'] .= ((imagecolorat($image, $x, $y) == 0) ? "0" : "1"); #echo $offsets[$o]['ident'].'<br>'; } } } return $offsets; } $a=""; foreach($letters as $letter){ $asciiletter = $database[$letter['ident']]; if(!empty($asciiletter)) { $a.=$asciiletter; } } Hello everyone.
please I have problem with printing out a value from inside an array of a nested json. ive tried several ways its always returns "index not define". $valr= "https://ice3.com/api/v1/orderbook/ticker"; ////////////////////////////source $valrGet = file_get_contents($valr); $valrD = json_decode($valrGet, true); $valrSell = ["ask"] ["price"]; Here is the structure of the json from the source : {"errors":false,"response":{"entities":[{"pair_id":3,"pair_name":"BTC\/ZAR","ask":{"price":"179382.54","amount":"0.05357142"},"bid":{"price":"177229.4286563","amount":"0.0011"}},{"pair_id":4,"pair_name":"BTC\/NGN","ask":{"price":"8890000.00","amount":"0.10"},"bid": my target is to output the value of ("price") from "pair_name" BTC\/ZAR please help. Thanks in advance Hello
This may seem like a silly question but if you never ask you never know...
Lets say I json encode a php array. When I echo out the encoded json string into a JS variable it looks something like this in the resultant markup:
var arr = ["cow - Copy (10).jpg","cow - Copy (2).jpg"];So in this instance the string I've echoed out is equivalent to a JS array and I can use it straight away. My questions: 1) Is it valid to do what I've done above? 2) Since I can use the array right away is there any need to JSON.parse? 3) When would you use JSON.parse? Thanks, Drongo Hello Can you please show me how can i parse this JSON in PHP? {"status":"error","error":{"error_code":700,"error_message":"Recognition failed: you didn't send file via POST or file url as `url` param."},"requested_params":{"method":"recognize"}}
I need to setup a condition : If(status="error) than $errorcode=700 errormessage=Recognition failed: you didn't send file via POST or file url as `url` param errorMethod= "recognize" Hello, I am a novice with php and know close to nothing about JSON. I am using wordpress and have 2 calendar type plugins I want to work together. With one plugin the user inputs dates that they are booked. The other plugin is a date picker, the cool part is it allows you to black out dates using php before the date picker is built. So what I'm trying to do is get the data from what the user chose as booked, and not let a user on the front end pick any of the booked dates with the date picker. Hope that makes sense. The problem is the formatting of the data with the date booked plugin. This is what is in the field Code: [Select] a:1:{s:9:"calendars";a:1:{i:1;a:4:{s:12:"calendarName";s:21:"Availability Calendar";s:12:"calendarJson";s:59:"{"year2011":{"month12":{"day25":"booked","day6":"booked"}}}";s:11:"dateCreated";i:1324333825;s:12:"dateModified";i:1324333825;}}} I chose 2 dates to be booked in that example: dec 25 2011, and dec 6 2011. I have no idea how I would parse the above data into what I need. I don't really need the data from the other parts of the above code, just the dates. The others are field descriptions and etc. that wordpress uses. Incidentally, this is what the date picker setup would look like in the above senario: Code: [Select] $myCalendar->setSpecificDate(array("2011-12-06","2011-12-25"), 0, ''); I need parse the JSON string below into an associative array, sort it by the 'age' field and output the sorted array as an HTML table. Here is what I have done so far but it just returns me 'Array': Code: [Select] <?php $json='[{"name": "John","age": 23},{"name": "jim","age": 19},{"name": "jason","age": 34}]'; $array = json_decode( $json, true); function cmp( $a, $b){ if( !isset( $a['age']) && !isset( $b['age'])){ return 0; } if( !isset( $a['age'])){ return -1; } if( !isset( $b['age'])){ return 1; } if( $a['age'] == $b['age']){ return 0; } return (($a['age'] > $b['age']) ? 1 : -1); } usort( $array, 'cmp'); foreach ($array as $key => $value) { echo $key.":".$value."\n"; } ?> I'm trying the fetch some geocode data from mapquest. Google doesn't like me right now. I keep running into the query_limit. So I want to set a back up that will go into production when I get that error from the big G. I have my api key and I can put the string in a var. Code: [Select] $geocode = file_get_contents($url) I selected json as the output and when I echo $geocode... here is the first portion of the string....(I want lat & lng) Code: [Select] renderOptions({"results":[{"locations":[{"latLng":{"lng":-112.35984,"lat":34.58752},..... Now for the life of me, I can't do anything with it. I've tried json_decode() with the true argument there and not. Code: [Select] $output = json_decode($geocode, true); $output = json_decode($geocode); vardump($output) is NULL. So, I thought, well maybe I don't need to decode it, but I can't figure out how to parse it. I'm lost. This admittedly is my first attempt as trying to work with a jason object, but jeesh, it doesn't seem like it should be that hard. Can someone start me in the right direction? Hello.
Server returns this json
{"status":1,"job_status":"READY","iterations":["Contig2","Contig75"],"accessions":["NP_001061702","NP_001068174"]}And i would like to print out in a textarea (using the above jQuery command) $('#info').val()something like this: Contig2 : NP_001061702 Contig75 : NP_001068174 Any idea on how to achieve this? Thanks! Hello.
I am new here.
I have a sligh problem, i saw a few results here which however did not lead to the desired result.
The problem is , i have this Json Response from a API:
Array ( [0] => Array ( [isoid] => 0 [omschrijving] => - leeg - ) [1] => Array ( [isoid] => 64 [omschrijving] => ArchLinux 2013.5 ) [2] => Array ( [isoid] => 75 [omschrijving] => AsteriskNOW 3.0.0 64b ) [3] => Array ( [isoid] => 67 [omschrijving] => CentOS 5.9 32b ) [4] => Array ( [isoid] => 2 [omschrijving] => CentOS 6.3 64b ) [5] => Array ( [isoid] => 96 [omschrijving] => CentOS 7.0 64b ) [6] => Array ( [isoid] => 4 [omschrijving] => Clear OS 5.2 64b ) [7] => Array ( [isoid] => 93 [omschrijving] => CloudLinux 6.4 ) [8] => Array ( [isoid] => 1 [omschrijving] => Debian GNU/Linux 6.0 / Squeeze 64b ) [9] => Array ( [isoid] => 79 [omschrijving] => Debian GNU/Linux 7.0 / Wheezy 32b ) [10] => Array ( [isoid] => 71 [omschrijving] => Debian GNU/Linux 7.0 / Wheezy 64b ) [11] => Array ( [isoid] => 63 [omschrijving] => Fedora 18 64b ) [12] => Array ( [isoid] => 82 [omschrijving] => FreeBSD 10 64b ) [13] => Array ( [isoid] => 77 [omschrijving] => FreeBSD 9.2 64b ) [14] => Array ( [isoid] => 10 [omschrijving] => FreePBX 5.211.65-12 ) [15] => Array ( [isoid] => 76 [omschrijving] => GParted Live CD ) [16] => Array ( [isoid] => 3 [omschrijving] => KVM Virtio drivers voor Windows ) [17] => Array ( [isoid] => 66 [omschrijving] => MailCleaner 2012v6 64b ) [18] => Array ( [isoid] => 68 [omschrijving] => Manjaro KDE 0.8.6 64b ) [19] => Array ( [isoid] => 78 [omschrijving] => Microsoft Windows 7 Pro 64b ) [20] => Array ( [isoid] => 69 [omschrijving] => Microsoft Windows Server 2003 EN ) [21] => Array ( [isoid] => 8 [omschrijving] => Microsoft Windows Server 2008R2 EN ) [22] => Array ( [isoid] => 7 [omschrijving] => Microsoft Windows Server 2008R2 NL ) [23] => Array ( [isoid] => 70 [omschrijving] => Microsoft Windows Server 2012 NL 64b ) [24] => Array ( [isoid] => 84 [omschrijving] => Microsoft Windows Server 2012R2 NL ) [25] => Array ( [isoid] => 83 [omschrijving] => NOC PS 1.0r11 ) [26] => Array ( [isoid] => 11 [omschrijving] => OpenBSD 5.2 ) [27] => Array ( [isoid] => 80 [omschrijving] => OpenBSD 5.4 ) [28] => Array ( [isoid] => 94 [omschrijving] => OpenBSD 5.5 64b ) [29] => Array ( [isoid] => 72 [omschrijving] => OpenSUSE 12.3 64b ) [30] => Array ( [isoid] => 95 [omschrijving] => Slackware 13.37 ) [31] => Array ( [isoid] => 12 [omschrijving] => System Rescue CD ) [32] => Array ( [isoid] => 18 [omschrijving] => Turnkey Appflower ) [33] => Array ( [isoid] => 19 [omschrijving] => Turnkey ASP.net/Apache ) [34] => Array ( [isoid] => 20 [omschrijving] => Turnkey Bugzilla ) [35] => Array ( [isoid] => 21 [omschrijving] => Turnkey CodeIgniter ) [36] => Array ( [isoid] => 22 [omschrijving] => Turnkey Django ) [37] => Array ( [isoid] => 23 [omschrijving] => Turnkey Dokuwiki ) [38] => Array ( [isoid] => 24 [omschrijving] => Turnkey DomainControler ) [39] => Array ( [isoid] => 25 [omschrijving] => Turnkey Drupal7 ) [40] => Array ( [isoid] => 26 [omschrijving] => Turnkey Fileserver ) [41] => Array ( [isoid] => 27 [omschrijving] => Turnkey Gallery ) [42] => Array ( [isoid] => 28 [omschrijving] => Turnkey Gitlab ) [43] => Array ( [isoid] => 15 [omschrijving] => Turnkey Google AppEngine Go ) [44] => Array ( [isoid] => 16 [omschrijving] => Turnkey Google AppEngine Java ) [45] => Array ( [isoid] => 17 [omschrijving] => Turnkey Google AppEngine Python ) [46] => Array ( [isoid] => 29 [omschrijving] => Turnkey IceScrum ) [47] => Array ( [isoid] => 30 [omschrijving] => Turnkey Joomla2.5 ) [48] => Array ( [isoid] => 31 [omschrijving] => Turnkey LAMP ) [49] => Array ( [isoid] => 32 [omschrijving] => Turnkey Lighttpd/PHP/FastCGI ) [50] => Array ( [isoid] => 33 [omschrijving] => Turnkey Magento ) [51] => Array ( [isoid] => 34 [omschrijving] => Turnkey Mediawiki ) [52] => Array ( [isoid] => 35 [omschrijving] => Turnkey MongoDB ) [53] => Array ( [isoid] => 36 [omschrijving] => Turnkey MySQL ) [54] => Array ( [isoid] => 37 [omschrijving] => Turnkey NGINX/PHP/FastCGI ) [55] => Array ( [isoid] => 38 [omschrijving] => Turnkey OpenLDAP ) [56] => Array ( [isoid] => 39 [omschrijving] => Turnkey OpenPhoto ) [57] => Array ( [isoid] => 40 [omschrijving] => Turnkey OSCommerce ) [58] => Array ( [isoid] => 41 [omschrijving] => Turnkey OTRS ) [59] => Array ( [isoid] => 42 [omschrijving] => Turnkey Owncloud ) [60] => Array ( [isoid] => 43 [omschrijving] => Turnkey PHPBB ) [61] => Array ( [isoid] => 44 [omschrijving] => Turnkey PHPList ) [62] => Array ( [isoid] => 45 [omschrijving] => Turnkey PHPNuke ) [63] => Array ( [isoid] => 46 [omschrijving] => Turnkey Postgresql ) [64] => Array ( [isoid] => 47 [omschrijving] => Turnkey Prestashop ) [65] => Array ( [isoid] => 48 [omschrijving] => Turnkey Rails ) [66] => Array ( [isoid] => 49 [omschrijving] => Turnkey Redmine ) [67] => Array ( [isoid] => 50 [omschrijving] => Turnkey SiTracker ) [68] => Array ( [isoid] => 51 [omschrijving] => Turnkey StatusNET ) [69] => Array ( [isoid] => 52 [omschrijving] => Turnkey SugarCRM ) [70] => Array ( [isoid] => 53 [omschrijving] => Turnkey Symfony ) [71] => Array ( [isoid] => 54 [omschrijving] => Turnkey Tomcat ) [72] => Array ( [isoid] => 55 [omschrijving] => Turnkey Tomcat/Apache ) [73] => Array ( [isoid] => 56 [omschrijving] => Turnkey TRAC ) [74] => Array ( [isoid] => 57 [omschrijving] => Turnkey TWiki ) [75] => Array ( [isoid] => 58 [omschrijving] => Turnkey Typo3 ) [76] => Array ( [isoid] => 59 [omschrijving] => Turnkey Wordpress ) [77] => Array ( [isoid] => 60 [omschrijving] => Turnkey Zencart ) [78] => Array ( [isoid] => 13 [omschrijving] => Ubuntu 10.04 32b ) [79] => Array ( [isoid] => 6 [omschrijving] => Ubuntu 10.04 64b ) [80] => Array ( [isoid] => 14 [omschrijving] => Ubuntu 12.04 32b ) [81] => Array ( [isoid] => 61 [omschrijving] => Ubuntu 12.04 64b ) [82] => Array ( [isoid] => 62 [omschrijving] => Ubuntu 12.10 64b ) [83] => Array ( [isoid] => 89 [omschrijving] => Ubuntu 14.04 LTS 64b ) [84] => Array ( [isoid] => 5 [omschrijving] => Windows Password Reset ) [85] => Array ( [isoid] => 81 [omschrijving] => Zen Loadbalancer 3.03 ) [86] => Array ( [isoid] => 74 [omschrijving] => Zentyal 3.2 ) )how would i go to fill it automatically in a option value like <option value='74'>Zentyal 3.2</option>Thank you in advance here are the three pages i am using to alter information stored in my database editrow.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table> <tr> <td align="center">EDIT DATA</td> </tr> <tr> <td> <table border="1"> <?php include"include/connect.php";//database connection $order = "SELECT * FROM products"; $result = mysql_query($order); while ($row=mysql_fetch_array($result)){ print " <td>" . $row["prod_id"] . "</td>"; print " <td>" . $row["prod_name"]. "</td>"; print " <td>" . $row["prod_price"] . "</td>"; print " <td>" . $row["prod_desc"]. "</td>"; print " <td>" . $row["prod_colour"] . "</td>"; print ("<td><a href=\"editform.php?id=$row[prod_id]\">Edit</a></td></tr>"); } ?> </table> </td> </tr> </table> </body> </html> then editform.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table border=1> <tr> <td align=center>Form Edit Employees Data</td> </tr> <tr> <td> <table> <?php include "include/connect.php";//database connection $id = $_GET['id']; $order = "SELECT * FROM products WHERE prod_id='$id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?> <form method="post" action="include/updatedata.php"> <input type="hidden" name="prodid" value="<? echo "$row[prod_id]"?>"> <tr> <td>Name</td> <td> <input type="text" name="prodname" size="20" value="<?php echo "$row[prod_name]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="prodprice" size="40" value="<?php echo "$row[prod_price]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="proddesc" size="40" value="<?php echo "$row[prod_desc]"?>"> </td> </tr> <tr> <td>Address</td> <td> <input type="text" name="prodcolour" size="40" value="<?php echo "$row[prod_colour]"?>"> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit value" value="Edit"> </td> </tr> </form> </table> </td> </tr> </table> </body> </html> now here it all goes weird i get this error Notice: Undefined index: $id in C:\wamp\www\uniwork\include\updatedata.php on line 4 but without it it doesnt know how to get the information from the previous form. include/updatedata.php <?php //edit_data.php include "connect.php"; $id=$_GET['$id']; $order = "UPDATE products SET prod_name='prodname', prod_price='prodprice', prod_desc='proddesc', prod_colour='prodcolour' WHERE prod_id='$id'"; mysql_query($order); header("location:updatedata.php"); ?> <?php session_start(); if($_SESSION['username']) echo "Welcome, ".$_SESSION['username']."!<BR>"; echo "<a href=\"logout.php\">LOGOUT</a>"; else die("Your Have To Be Logged In To View This Page"); ?> anyone see anything wrong with this i'm getting a parse error on line 8 that is the else statment <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect:' . mysql_error()); } mysql_select_db("Products", $con); $status = $_POST["c1"]; $result=mysql_query("SELECT * FROM btp_reviews ORDER BY status =".$status.""); mysql_db_query("Products", $result) or die("Failed Query of " . $result); mysql_close($con); ?> I have some PHP code that should give me the dates in year order but it is giving me the date order. So it shows a list of 10 items in the following order see attached png it should show the ten items i sorted by year then month then day, <?php $sql = "SELECT GAME, YR, PLATFORM, PUBLISHER, FINISHED FROM games WHERE COMPLETED='✔' ORDER BY FINISHED DESC LIMIT 10;"; $result = mysqli_query($conn, $sql) or die("Bad Query: $sql"); $num_rows = mysqli_num_rows($result);?> <?php while ($row = mysqli_fetch_assoc($result)): ?> <tr> <td><?php echo $row['GAME']; ?></td> <td><?php echo $row['PLATFORM']; ?></td> <td><?php echo date('d F Y', strtotime($row['FINISHED'])); ?></td> <tr> <?php endwhile; ?> This use to work on until this week
Hello Guys n Gals too.. I have this big problem thats driving me nuts!! I have this login page that is not working. when i put the username n password all it does is reload itself. Alot of pages depend on the login and they dont work cozz login doesnt So please help me out. Thanx. Heres the code: Code: [Select] <?php include ("./common.php"); include ("./Header.php"); include ("./Footer.php"); // Login CustomIncludes end //------------------------------- session_start(); //=============================== // Save Page and File Name available into variables //------------------------------- $sFileName = "Login.php"; $sAction = get_param("FormAction"); $sForm = get_param("FormName"); //=============================== // Login Show begin //=============================== // Perform the form's action //------------------------------- // Initialize error variables //------------------------------- $sLoginErr = ""; //------------------------------- // Select the FormAction //------------------------------- switch ($sForm) { case "Login": Login_action($sAction); break; } //=============================== //=============================== // Display page //=============================== // HTML Page layout //------------------------------- ?><html> <head> <title>Pablo Online Rent-a-Car</title> <meta name="GENERATOR" content="Philmar"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head> <body style="background-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helveticabackground-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica"> <center> <table> <tr> <td valign="top"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Pablo Online Rent-a-Car</title> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/mazda6_1.jpg','images/home_2.jpg','images/aboutus_2.jpg','images/contactus_2.jpg')"> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/header1.jpg" width="778" height="110"></td> </tr> </table> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="55"><img src="images/header2.jpg" width="55" height="43"></td> <td width ="17"><a href="default.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('home','','images/home_2.jpg',1)"><img src="images/home_1.jpg" alt="home" name="home" width="63" height="43" border="0"></a></td> <td width ="114" valign="middle"><a href="about.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('aboutphilmar','','images/aboutus_2.jpg',1)"><img src="images/aboutus_1.jpg" alt="aboutphilmar" name="aboutphilmar" width="114" height="43" border="0"></a></td> <td width ="111"><a href="contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contactus','','images/contactus_2.jpg',1)"><img src="images/contactus_1.jpg" alt="contactus" name="contactus" width="108" height="43" border="0"></a></td> <td width ="455"><img src="images/header3.jpg" width="438" height="43"></td> </tr> </table> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="55"><img src="images/header4.jpg" width="55" height="48"></td> <td> </td> <td width="438"><img src="images/header5.jpg" width="438" height="48"></td> </tr> </table> <?php Menu_show() ?> </td> </tr> </table> </center> <table width="760" align="center"> <tr> <td align="center"> <hr color="#800000"><center> <table> <tr> <td valign="top"> <?php Login_show() ?> </td> </tr> </table> <hr color="#800000" width="60%"> </td> </tr> </table> <center> <table> <tr> <td valign="top"> <?php Footer_show() ?> </td> </tr> </table> </center> </body> </html> <?php // Login Show end //=============================== // Login Close Event begin // Login Close Event end //=============================== //******************************************************************************** //=============================== // Login Form Action //------------------------------- function Login_action($sAction) { global $db; global $sLoginErr; global $sFileName; global $styles; switch(strtolower($sAction)) { case "login": //------------------------------- // Login Login begin //------------------------------- $sLogin = get_param("Login"); $sPassword = get_param("Password"); $db->query("SELECT member_id,member_level FROM members WHERE member_login =".$sLogin. " AND member_password=".$sPassword.""); $is_passed = $db->next_record(); //------------------------------- // Login OnLogin Event begin // Login OnLogin Event end //------------------------------- if($is_passed) { //------------------------------- // Login and password passed //------------------------------- set_session("UserID", $db->f("member_id")); set_session("UserRights", $db->f("member_level")); $sPage = get_param("ret_page"); if (strlen($sPage)) header("Location: " . $sPage); else header("Location: Reservation.php"); } else { $sLoginErr = "Login or Password is incorrect."; } //------------------------------- // Login Login end //------------------------------- break; case "logout": //------------------------------- // Logout action //------------------------------- //------------------------------- // Login Logout begin //------------------------------- //------------------------------- // Login OnLogout Event begin // Login OnLogout Event end //------------------------------- session_unregister("UserID"); session_unregister("UserRights"); if(strlen(get_param("ret_page"))) header("Location:" . $sFileName . "?ret_page=" . urlencode(get_param("ret_page"))); else header("Location:" . $sFileName); //------------------------------- // Login Logout end //------------------------------- break; } } //=============================== //=============================== // Display Login Form //------------------------------- function Login_show() { global $sLoginErr; global $db; global $sFileName; global $styles; $querystring = get_param("querystring"); $ret_page = get_param("ret_page"); $sFormTitle = "Enter username and password"; //------------------------------- // Login Show begin //------------------------------- //------------------------------- // Login Open Event begin // Login Open Event end //------------------------------- ?> <table style="width:100%"> <form action="login.php" method="POST"> <input type="hidden" name="FormName" value="Login"> <tr><td style="background-color: #336699; text-align: Center; border-style: outset; border-width: 1" colspan="2"><font style="font-size: 10pt; color: #FFFFFF; font-weight: bold"><?=$sFormTitle?></font></td></tr> <? if ($sLoginErr) { ?> <tr><td colspan="2" style="background-color: #FFFFFF; border-width: 1"><font style="font-size: 10pt; color: #000000"><?= $sLoginErr ?></font></td></tr> <? } ?> <? if(get_session("UserID") == "") { //------------------------------- //- User is not logged in //------------------------------- ?> <tr><td style="background-color: #FFEAC5; border-style: inset; border-width: 0"><font style="font-size: 10pt; color: #000000">Login</font></td><td style="background-color: #FFFFFF; border-width: 1"><input type="text" name="Login" value="<?=tohtml(get_param("Login"))?>" maxlength="50"></td></tr> <tr><td style="background-color: #FFEAC5; border-style: inset; border-width: 0"><font style="font-size: 10pt; color: #000000">Password</font></td><td style="background-color: #FFFFFF; border-width: 1"><input type="password" name="Password" maxlength="50"></td></tr> <tr><td colspan="2"> <input type="hidden" name="FormAction" value="login"> <input type="submit" value="Login"> </td></tr> <? } else { //------------------------------- // User is logged in //------------------------------- $db->query("SELECT member_login FROM members WHERE member_id=". get_session("UserID")); $db->next_record(); ?> <tr><td style="background-color: #FFFFFF; border-width: 1"><font style="font-size: 10pt; color: #000000"> <?= $db->f("member_login") ?></font> <input type="hidden" name="FormAction" value="logout"> <input type="submit" value="Logout"> </td></tr> <? } ?> <input type="hidden" name="ret_page" value="<?= $ret_page ?>"><input type="hidden" name="querystring" value="<?= $querystring ?>"></td></tr> </form></table> <? } ?> <? include_once ("../includes/config.php"); include_once "../includes/dbconnect.php"; header("Content-type: image/jpeg"); $id = $_REQUEST['id']; $sql="SELECT product_image FROM tbl_product WHERE product_id='$id' "; $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $image= $row['product_image']; $image=imagecreatefromstring($image); $out=ImagejpeG($image); print ($out); }?> Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Dairy Farm Record Management</title> <link rel="stylesheet" type="text/css" href="C:\Documents and Settings\satheesh\Desktop\dairy_records\styles\styles.css" /> </head> <body bgcolor="#FFEBCC"> <?php if ( isset($_POST["submit"])) { // process form //$db = mysql_connect("localhost", "root","TWINKLE1"); //mysql_select_db("c1_cattle_history",$db); //$sql = "INSERT INTO cattle_rec (cattle_name,first_svc,second_svc,third_svc,calving_date,calf_sex,days_in_milk,milk_yld,dry_days,305_days_yld) VALUES //('$cattle_name,$first_svc,$second_svc,$third_svc,$calving_date,$calf_sex,$days_in_milk,$milk_yld,$dry_days,$days_yld')"; //$result = mysql_query($sql); require($_SERVER["DOCUMENT_ROOT"]."/dairy_logon.php"); $connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting"); mysql_select_db("$db_name"); mysql_query("INSERT INTO cattle_det (cattle_n,first_s,second_s,third_s,calving_d,calf_s,days_m,m_yld,dry_d,d_yld) VALUES ('$_POST[cattle_name]','$_POST[first_svc]','$_POST[second_svc]','$_POST[third_svc]','$_POST[calving_date]','$_POST[calf_sex]','$_POST[days_in_milk]','$_POST[milk_yld]','$_POST[dry_days]','$_POST[days_yld]')"); echo "Cattle Information Updated Successfully !\n"; } else { // display form } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table cellpadding="0" cellspacing="0" width="99%"> <tr><td align="center"> <font face="Franklin Gothic Medium" size="6" color="#FF8000">History Sheet</font></td></tr><br/> <tr><td align="left"><font face="Franklin Gothic Medium" size="4" color="#FF8000">Cattle Name : </font> <input type="text" size="15" name="cattle_name"></input><br/> </td></tr><br/> <table border="2" cellpadding="1" cellspacing="0" id="mytable"> <tr> The code given above is supposed to retrieve values from a form and update the respective columns in the MySQL database,but everytime I key-in the value and say "Submit" in the form the form is just reset and the values are also getting updated. Please do provide your valuable inputs. Thanks a mil. Satheesh P R <?php require_once("includes/connection.php");?> <html> <head> <style type="text/css"> <!-- a:link { color: #000000; text-decoration: none; } a:visited { text-decoration: none; color: #000000; } a:hover { text-decoration: underline; color: #FFFFFF; } a:active { text-decoration: none; color: #000000; } a { font-family: Courier New, Courier, monospace; } body,td,th { font-family: Courier New, Courier, monospace; font-size: 18px; } .style1 {font-size: 40px} #one { text-align:center; vertical-align:top; } #parent { position:absolute; left:60px; font-size:14px; } --> </style> </head> <body> <table width="100%" height="888" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="186" colspan="2" bgcolor="#CCCCCC"><div align="center" class="style1">DOWNLOAD TREASURE </div></td> </tr> <tr> <td id="one" width="16%" bgcolor="#99CCFF" ><?php $result =mysql_query("SELECT * FROM subjects",$connection); if(!$result){ die("connection error : ".mysql_error()); } while($row = mysql_fetch_array($result)){ echo $row["menu_name"]."<br/>"; } $parent = mysql_query("SELECT * FROM pages WHERE subject_id = {$row["id"]}" ,$connection); if(!$parent){ die("connection error : ".mysql_error()); } while($rowone = mysql_fetch_array($parent)){ echo $rowone["menu_name"]; } ?></td> <td width="84%"> </td> </tr> </table> </body> </html> is there any mistake here.it is a big help for me. Code goes no place but changes some figures on the tool bar. Code: [Select] <?php ini_set('display_errors', 1); error_reporting(E_ALL); function OnSubmitForm() { $choose = ""; $variable1 = ""; $variable2 = ""; $choose = $_GET["pages"]; $variable1 = $_GET["page1"]; $variable2 = $_GET["page2"]; if ($choose == $variable1) { header("Location: http://url.com/page1"); } if ($choose == $variable2) { header("Location: http://url.com/page2"); } } ?> <form name="pages" onsubmit="return OnSubmitForm()"> <input type="text" name="call" size="25"> e<select name="pages"> <option name="page1" value="non1">page1</option> <option name="page2" value="non2">page2</option> </select> <input type="submit" name="submit" value="submit"> </p> </form> Hi, I have a registration page (that one works fine) where users register with minimal personal info. They also get to rate 8 categories (see bellow) 1-5. Once they hit submit it all goes into database just fine. I have also created a page for myself where I can recall all data for any registration. All data gets pulled from database correctly. When I change variables and hit submit it does not update the record in the database. I get no errors from the script, but I have narrowed the problem to the recall of categories and the ratings. If I remove them from the update script other info gets stored correctly. Here is how I recall the 8 categories and their user submitted ratings (as well as other info): Code: [Select] $category = array('AS','BE','BI','CH','CS','EG','EV','PH'); foreach ($category as $cat) { if ($cat == 'AS') $cat_name = 'Animal Sciences'; if ($cat == 'BE') $cat_name = 'Behavioral & Social Sciences'; if ($cat == 'BI') $cat_name = 'Biology'; if ($cat == 'CH') $cat_name = 'Chemistry'; if ($cat == 'CS') $cat_name = 'Computer Science'; if ($cat == 'EG') $cat_name = 'Engineering'; if ($cat == 'EV') $cat_name = 'Environmental Sciences'; if ($cat == 'PH') $cat_name = 'Physical Sciences'; echo" <tr> <td>$cat_name</td>"; $numbers = array('0','1','2','3','4','5'); foreach ($numbers as $no) { echo "<td><input type='radio' name='$cat' value='$no'"; if ($row[$cat] == $no) echo " checked/>"; else echo "/>"; echo"$no</td>"; }} And here is how I update the record (as well as other info not listed): Code: [Select] mysql_query("UPDATE registrations SET AS = '$_POST[AS]', BE = '$_POST[BE]', BI = '$_POST[BI]', CH = '$_POST[CH]', CS = '$_POST[CS]', EG = '$_POST[EG]', EV = '$_POST[EV]', PH = '$_POST[PH]' WHERE ID = '$_POST[ID]' "); Something in my recall code is creating issued for me, but I have no idea what. Thanks |