• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Php/js help

Kavvson

Gdy boli cie glowa wez
Joined
Jun 25, 2008
Messages
1,177
Reaction score
72
Location
Poland
Modern AAC - JSON/PHP - Injection

How can i merge the 2 files?

Show.php How to reconvert it into one file the both files. How can i merge them and pass the standalone sql connection.

PHP:
<?php
	//connection information
	$host = "localhost";
	$user = "root";
	$password = "";
	$database = "mod";
	$param = $_GET["term"];

	//make connection
	$server = mysql_connect($host, $user, $password);
	$connection = mysql_select_db($database, $server);
	
	//query the database
	$query = mysql_query("SELECT name FROM players WHERE name REGEXP '^$param' LIMIT 30");
	
	//build array of results
	for ($x = 0, $numrows = mysql_num_rows($query); $x < $numrows; $x++) {
		$row = mysql_fetch_assoc($query);
    
		$players[$x] = array("name" => $row["name"]);		
	}
	
	//echo JSON to page
	$response = $_GET["characters"] . "(" . json_encode($players) . ")";
	echo $response;
	
	mysql_close($server);
	
?>

and

Injection.php

HTML:
<?PHP
if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );
global $config;
?>

<script>
$(function(){
				//attach autocomplete
				$("#search").autocomplete({
					//define callback search format results
					source: function(req, add){
						//pass request search server

						$.getJSON("http://127.0.0.1/trunk.r123/injections/character_search/Autocomplete/show.php?characters=?", req, function(data) {
							//create array for response objects
							var suggestions = [];
							//process response
							$.each(data, function(i, val){								
								suggestions.push(val.name);
							});
							//pass array search callback
							add(suggestions);
						});
					},
				});
			});
			
		function fill(thisValue) {
		$('#search').val(thisValue);
	}

</script>


<style type="text/css">
	#resizable { width: 97%; height: 100px; padding: 0.5em; }
	#resizable h3 { text-align: center; margin: 0; height 10px;}
	</style>

<div id="resizable" class="ui-widget-content">
	<h3 class="ui-widget-header">Search Character</h3>
	<br>
<label>Character name</label>
<div id="characters" class="ui-helper-clearfix">
<input id="search" name="name" type="text" onblur="fill();">&nbsp &nbsp &nbsp <button type="submit" name="Submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">&nbsp Search &nbsp </span></button>
</form>
</div>
</div>

in one file.. since it get some troubles while making
 
Last edited:
Not entirely sure what you want but...

PHP:
   <?php

    // Check for defined BASEPATH?
    if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );
    global $config;

    //connection information
    $host = "localhost";
    $user = "root";
    $password = "";
    $database = "mod";
    $param = $_GET["term"];

    //make connection
    $server = mysql_connect($host, $user, $password);
    $connection = mysql_select_db($database, $server);
    
    //query the database
    $query = mysql_query("SELECT name FROM players WHERE name REGEXP '^$param' LIMIT 30");
    
    //build array of results
    for ($x = 0, $numrows = mysql_num_rows($query); $x < $numrows; $x++) {
        $row = mysql_fetch_assoc($query);
    
        $players[$x] = array("name" => $row["name"]);        
    }
    
    //echo JSON to page
    $response = $_GET["characters"] . "(" . json_encode($players) . ")";
    echo $response;
    
    mysql_close($server);
    
?> 

<script>
$(function(){
				//attach autocomplete
				$("#search").autocomplete({
					//define callback search format results
					source: function(req, add){
						//pass request search server

						$.getJSON("http://127.0.0.1/trunk.r123/injections/character_search/Autocomplete/show.php?characters=?", req, function(data) {
							//create array for response objects
							var suggestions = [];
							//process response
							$.each(data, function(i, val){								
								suggestions.push(val.name);
							});
							//pass array search callback
							add(suggestions);
						});
					},
				});
			});
			
		function fill(thisValue) {
		$('#search').val(thisValue);
	}

</script>


<style type="text/css">
	#resizable { width: 97%; height: 100px; padding: 0.5em; }
	#resizable h3 { text-align: center; margin: 0; height 10px;}
	</style>

<div id="resizable" class="ui-widget-content">
	<h3 class="ui-widget-header">Search Character</h3>
	<br>
<label>Character name</label>
<div id="characters" class="ui-helper-clearfix">
<input id="search" name="name" type="text" onblur="fill();">&nbsp &nbsp &nbsp <button type="submit" name="Submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">&nbsp Search &nbsp </span></button>
</form>
</div>
</div>

Like said, I've just mashed them together, can't really do anything else since I don't know what you want.
 
Its not it :) learn some basics and write then the spoils. Ur code is useless


Dude, what the hell?

You ask people to merge the two files for you. Since you lack the knowledge to do it yourself, and apparently also the willingness to learn how to do it yourself.
You also leave little to no info as to what you want done.

I decide to help you, and mash together the two files. Since that's all you asked for; "merge 2 files".

Not entirely sure what you want but...

Like said, I've just mashed them together, can't really do anything else since I don't know what you want.

Despite this, you call me a "nob" and even tell me to "learn some basics" just so that I can do something for you that you're too lazy to do yourself.


Go learn some manners. Seriously.
 
Back
Top