Ok So I have this PHP class that talks to a Javascript class that basically creates a table of information from a database query and puts it in a sortable, filterable table. This all works fine and dandy.
Well, i have had the need for some semi-dynamic functionality (changing the table of the query, or changing some other detail) which I accomplished using GETS. This also worked perfectly
I wanted to try to add some AJAX functionality in place of the GET functionality, so I changed things around a bit, and now I am sending an xmlhttprequest to my php page. this requests fine. however, I do not get back the information I want. Here is the PHP page that I send the request to
require('page.php');
function getAssoc($query, $table){
$svname = 'list_users';
$svuser = 'dmitriyy';
$svpass = 'dmitriyy';
$oracle = new oracle($svname, $svuser, $svpass);
//var_dump($oracle);
$query = str_replace('REPLACE_ME', $table, $query);
//var_dump($query);
//echo $query."<br />";
//echo "execute is here bitch";
echo $query;
$execute = $oracle->query$query);
while(OCIFetchInto($execute, $results, OCI_ASSOC)){
if ($data == null){
$data = array();
$data[] = $results;
}
else {
$data[] = $results;
}
}
return $data;
}
$query = $_GET['q'];
$table = $_GET['t'];
print_r(getAssoc($query, $table));
echo "done with print_r";
//echo json_encode(getAssoc($query, $table));
page.php (just a small class that does some oracle database connection and query stuff. This class DOES work, as I use it everywhere)
class oracle {
//class variables
var $connection;
/*Constructor
*Input (Server name, server usename, server password. By default
*server name is localhost, and password and user are blank
*returns true if connection was successful, false if not
*/
function oracle($svname, $svuser, $svpass){
//echo "<script type='text/javascript'>alert('".$svname."');</script>";
try {
$conn = oci_connect($svuser, $svpass, $svname);
if (!$conn){
throw new Exception("Error");
}
}
catch(Exception $e){
trigger_error($e->getMessage());
exit();
}
$this->connection = $conn;
if (!$conn){
echo "<script type='text/javascript'>alert('COULD NOT CONNECT');</script>";
return false;
}
return true;
}//end Constructor
//class functions
/*query_valid
*Input: A query String
*Returns the string if it is valid. String cannot have insert or update commands
*returns false if it does
*/
public function is_valid($string){
$temp = strtoupper($string);
$invalid_commands = array("INSERT", "DELETE", "UPDATE", "DROP", "TRUNCATE", "APPEND");
foreach($invalid_commands as $c){
if (strpos($temp, $c) !== false){
return false;
}
}
return true;
}
/*query
*Input: A (hopefully valid) oracle query
*returns the parsed query if execution was valid
*returns false if not
*/
public function query($query){
if (!$this->is_valid($query)){
die ("Query Contains Illegal Command! Exiting script");
}
$do = oci_parse($this->connection, $query);
$go = oci_execute($do);
if (!$go){
return false;
}
return $do;
}
/*BubbleSort2
*Sorts a 2d array, based on a certain column (sorts numerically)
*returns the sorted array
*/
public function BubbleSort2($sort_array,$column = 0,$reverse = true){
$lunghezza=count($sort_array);
for ($i = 0; $i < $lunghezza ; $i++){
for ($j = $i + 1; $j < $lunghezza ; $j++){
if($reverse){
if ($sort_array[$i][$column] < $sort_array[$j][$column]){
$tmp = $sort_array[$i];
$sort_array[$i] = $sort_array[$j];
$sort_array[$j] = $tmp;
}
}else{
if ($sort_array[$i][$column] > $sort_array[$j][$column]){
$tmp = $sort_array[$i];
$sort_array[$i] = $sort_array[$j];
$sort_array[$j] = $tmp;
}
}
}
}
return $sort_array;
}
}
ignore the bubblesort
On the ajax page (the first snippet) everything seems to work fine until I try to build that data array. It just returns empty. I have verified that it is the exact same query on the main page (which executes the query successfully) and the ajax page.
One thing to note. I pass the query from php to javascript, and then back to PHP again. I use json_decode when passing to javascript from PHP. However, this doesn't seem to have an effect on the query, as I checked them, and they appear to be the same. Im really at a loss for why this isn't working.
is what i'm trying to do possible? I think it is but im not sure any more... anyone have any insight
InternetOpenUrl() Invalid cert
Hi all,
downloading a file as HTML
Hi.I'm rather confused with forcing a download. I just want to save dynamic content (from $_SESSION[''] data) as a .html file.The script to do this is a PHP page, but when I click on
sql error
I have been looking at this code for 20mins and can't work out what I am doing wrong. There is something wrong with my sql statement below is the error and the code. what I am trying to do is to edit
Option box to change variable
Hello, i need help by making a script!I need to write a file with option box, so a dropdown menu with 10 or more options, and when i select one option a button to save this option to a php variable in
Reg Ex
Im trying to search for the string: srv_9 (Dead ???)I thought to use preg_match, however I dont know much about reg ex. Can anyone help? Thankks
writing my own sobel filter convolution - something is wrong
I am trying to keep it very simple, I cant see anything wrong with my logic, could anybody help point me to the right direction?!! Code: { int Shorizontal[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; int
temporary objects
Until now i thought every temporary object in C++ is created as constant. I'm wondering why my compiler (gcc) is reporting an error on line k.f();, but not g().f(); and g() = k;. Does anyone
elseif help!
OK so I'm new to the site, as well as PHP altogether (Trying my hand at managing an online RPG) and so far it's been quite smooth. However whilst trying to change an aspect of the game from giving the
Insert data in Mysql and move to another page
I'm stuck with this simple problem. I need to insert data in Mysql and then hit submit and move to another page. My first thougt was to use Post but that didn't work. How do I use Get and Post to do
Echoing ASCII code
I have a php page that splits a string into chars and then echoes the ASCII code for each char. I'm trying to get it print the original value => ASCII code, splitted by :, like:A => 65: