Jump to content

RP

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

RP's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I havent switched server or touched anything, i almost wish i had so i could find the problem. Running phpinfo() and doing a find for json came up with only one result under Configure Command; '--with-zip=/usr' '--with-json' '--with-pear' '--enable-utf8' '--enable-track-vars' '--enable-trans-sid' Im not sure exactly what this means but i do know that i was perviously able to watch firebug display my Json string and in turn watch it build my graph.
  2. if this was the problem how was it generating strings before i lost my working version?
  3. bump becasue i still cant make this work and i dont have much more hair to pull out.
  4. The Dataset links into this piece of code: <script> Object.extend(Plotr.LineChart.prototype,{ getRemoteDatasetAndRender: function(url) { var xhr_options = { method: 'get' } xhr_options.onComplete = function(xhr) { var json = eval('('+xhr.responseText+')'); this.addDataset(json.dataset); this.setOptions(Object.extend(this.options,json.options)); this.render(); }.bind(this); new Ajax.Request(url,xhr_options); } }); //we won't include the axis details in the options, // as the remote call will provide them var options = { padding: {left: 30, right: 0, top: 10, bottom: 30}, backgroundColor: '#dbdbdb', colorScheme: 'red' }; var line = new Plotr.LineChart('plotr',options); //then just pass the URL to the function line.getRemoteDatasetAndRender('dataset4pm.php'); </script> Would this undefiend function apply even for the default example i listed in my first post?
  5. no dice : ( still getting a fatal error on line 64 - $return = json_encode($return);
  6. So i was working on this script last night and had it working fairly well, i came back in the morning and made some alts, only to have my computer crash and as per usual i had saved a unworking version and couldnt revert. My last version of the page was at 4pm, however its not working. It is constantly giving me an "Fatal error: Call to undefined function: json_encode() on line 64". Last night it was delivering me a Json array like it should be. <?php $code = "user 2"; if (!$db = mysql_connect($host, $user, $pass)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db($dbname, $db)) { echo 'Could not select database'; exit; } $query = "SELECT * FROM graph WHERE username = '$code'"; $result = mysql_query($query); $num = mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $value0=mysql_result($result,$i,"value0"); $value1=mysql_result($result,$i,"value1"); $value2=mysql_result($result,$i,"value2"); $value3=mysql_result($result,$i,"value3"); $value4=mysql_result($result,$i,"value4"); $i++; } $dataset = array( 'ds1'=>array( array(0,$value0), array(1,$value1), array(2,$value1), array(3,$value3), array(4,$value4) ) ); $options = array( 'xTicks'=>array( array('v'=>0,'label'=>'Mon'), array('v'=>1,'label'=>'Tue'), array('v'=>2,'label'=>'Wed'), array('v'=>3,'label'=>'Thur'), array('v'=>4,'label'=>'Fri') ) ); $return = array( 'dataset'=>$dataset, 'options'=>$options ); header("Content-type: text/json"); echo json_encode($return); ?> Doing some reaserach i tried using the default php example for json_encode(); <?php $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); echo json_encode($arr); ?> this gave me a fatal error as well. Nothing has changed on my server at all. So i ask you PhpFreaks.com, WTF is going on? and furthermore, how do i fix it?
  7. cheers guys, worked a treat. many thanks.
  8. Im having a little trouble selecting from my tables while im trying to make some dynamically generated content; This code works a treat; <?php $host = ""; $user = ""; $pass = ""; $dbname = ""; if (!$db = mysql_connect($host, $user, $pass)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db($dbname, $db)) { echo 'Could not select database'; exit; } // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); //XML Header header("content-type:text/xml"); $query = "SELECT * FROM locations"; $query = mysql_query($query); echo "<locations>"; while ($row=mysql_fetch_assoc($query)){ echo '<location id="'.$row['location_id'].'" station="'.$row['station'].'" lat="'.$row['lat'].'" lng="'.$row['lng'].'" />'; } echo "</locations>"; ?> but its not what i need, i need to be able to select according to a variable passed from a form ($code), so im trying this; <?php $code = $_POST['id']; $code = strtoupper($code); $host = ""; $user = ""; $pass = ""; $dbname = ""; if (!$db = mysql_connect($host, $user, $pass)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db($dbname, $db)) { echo 'Could not select database'; exit; } // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); //XML Header header("content-type:text/xml"); $query = "SELECT * FROM locations WHERE id1 = '$code' || id2 = '$code' || id3 = '$code' || id4 = '$code' || id5 = '$code'"; $query = mysql_query($query); echo "<locations>"; while ($row=mysql_fetch_assoc($query)){ echo '<location id="'.$row['location_id'].'" station="'.$row['station'].'" lat="'.$row['lat'].'" lng="'.$row['lng'].'" />'; } echo "</locations>"; ?> any my output is consistently <locations></locations>, despite the $code variable being in the id1 column. Any ideas as to what im doing wrong would be greatly appreciated. Cheers.
  9. Thanks that worked perfectly. Like i said im very new at this so im not suprided my code is designed badly, any tips would be appreicated.
  10. Title says it all, im kinda new at this so im really hoping you guys can help me out. Ive been asked to make a SQL driven google maps mashup, the page has a submit form which a passes a varible to the SQL called $code, This varible is then used in the selct statement. My table has has multiple id feilds (id1, id2, id3, id4, id5) and id like to search all of them for the %code variable. I have gotten the code working perfectly searching just one of the id feilds (as below), but when i try to search more than one it returns 'no results'. include("dbinfo.php"); mysql_connect('$main',$username,$password); mysql_select_db($database) or die( "Unable to select database : " . mysql_error()); $result = mysql_query("SELECT * FROM gmaps WHERE id1 = '$code'"); if (!$result) { echo "no results"; } while($row = mysql_fetch_array($result)) { echo "var point = new GPoint(" . $row['long'] . "," . $row['lat'] . ");\n"; echo "var marker = createMarker(point, '<div id=\"infowindow\" style=\"white-space: nowrap;\"><p><strong>" . addslashes($row['station']) . "</strong><br /><a href=\"javascript:ajaxpage(\'ajaxfiles/" . addslashes($row['html']) . ".htm\',\'rightcolumn\')\">Learn More</a></p></div>');\n"; echo "map.addOverlay(marker);\n"; echo "\n"; } mysql_close(); Everything ive read says that to achive this all i need to do is this : $result = mysql_query("SELECT * FROM gmaps WHERE id1, id2, id3, id4, id5 = '$code'"); but that isnt working either, simply returning 'no result'. Ive tried with apostrophes, without apostrophes, with full text strings (idone, idtwo ect.), still no dice. any ideas? id really appreciate the help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.