hi!
I have problems to give the value of a text.
I have in a PHP this:
<?php
$searchq = strip_tags($_GET['q']);
$getRecord_sql = 'select pkey from jiraissue where project = 10040 and pkey like "%'.$searchq.'%"';
$getRecord = mysql_query($getRecord_sql);
if(strlen($searchq)>0){
echo '<ul>';
while ($row = mysql_fetch_array($getRecord)) {
?>
<li><a href="lib/consultas.php?accion=E" onclick="load('lib/consultas.php?accion=E','consulta');return false;">
and in my file consultas.php, the case E:
case 'E':
$queEmp = "select pkey, created, UPDATED, reporter, assignee, summary, description from `jiraissue` where project = 10040 and pkey like ".$search-q2." ";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) {
echo "<strong>Incidencia:</strong> <u>".$rowEmp['pkey']."</u><br>";
echo "<strong>Data:</strong> ".$rowEmp['created']." / ".$rowEmp['UPDATED']."<br>";
echo "<strong>Tecnic Obre:</strong> ".$rowEmp['reporter']."<br>";
echo "<strong>Tecnic Actual:</strong> ".$rowEmp['assignee']."<br>";
echo "<strong>Descripcio incidencia:</strong> ".$rowEmp['summary']."<br>";
echo "<strong>Intervencions:</strong> ".$rowEmp['description']."<br><br>";
}
}
break;
mysql_close($conexion);
Why the result of my query is:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0' at line 1
Brandoe85 08-12-2008, 02:06 PM Echo out your sql statement for debugging. What do you get?
in witch part? If i select one item of my text box, I would like to make any echo to say: you're selected the item X! how?
masterofollies 08-12-2008, 03:53 PM Echo it like this.
$descript = $rowEmp["description"];
echo "$descript";
Brandoe85 08-12-2008, 03:59 PM I meant echo $queEmp and debug it.
next the case E I insert:
case 'E':
echo "hello value!: <br>";
echo ?????
but, in ???? what's the value of my selected AutoSuggest content into the text box?
abduraooft 08-12-2008, 04:20 PM $queEmp = "select pkey, created, UPDATED, reporter, assignee, summary, description from `jiraissue` where project = 10040 and pkey like ".$search-q2." "; what's that - mean?
And what Brandoe85 saying is to echo your query like
echo $queEmp = "select pkey, created, UPDATED, repor...........
$search-q2 is the name of the variable of the text box. not's correct??
I can't debug the $queEmp because in $queEmp are my query and it doesn't run...
this is the text box into a index.php:
<input name="search-q2" id="search-q2" type="text" onkeyup="javascript:autosuggest2()"/>
and into the consultas.php, the case E:
case 'E':
$queEmp = "select `pkey`, `created`, `UPDATED`, `reporter`, `assignee`, `summary`, `description` from `jiraissue` where project = 10040 and `pkey` like ???VARIABLE???? ";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) {
echo "<strong>Incidencia:</strong> <u>".$rowEmp['pkey']."</u><br>";
echo "<strong>Data:</strong> ".$rowEmp['created']." / ".$rowEmp['UPDATED']."<br>";
echo "<strong>Tecnic Obre:</strong> ".$rowEmp['reporter']."<br>";
echo "<strong>Tecnic Actual:</strong> ".$rowEmp['assignee']."<br>";
echo "<strong>Descripcio incidencia:</strong> ".$rowEmp['summary']."<br>";
echo "<strong>Intervencions:</strong> ".$rowEmp['description']."<br><br>";
}
}
break;
mysql_close($conexion);
and I have a Framework:
function autosuggest1() {
q = document.getElementById('search-q2').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search_incidencias.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggestReply() {
if(http.readyState == 4){
var response = http.responseText;
e = document.getElementById('results');
if(response!=""){
e.innerHTML=response;
e.style.display="block";
} else {
e.style.display="none";
}
}
}
and, search_incidencias.php:
<?php
$searchq = strip_tags($_GET['q']);
$getRecord_sql = 'SELECT `pkey` FROM `jiraissue` WHERE project = "10040" and `pkey` LIKE "%'.$searchq.'%"';
$getRecord = mysql_query($getRecord_sql);
if(strlen($searchq)>0){
echo '<ul>';
while ($row = mysql_fetch_array($getRecord)) {
?>
<li><a href="lib/consultas.php?accion=E" onclick="load('lib/consultas.php?accion=E','consulta');return false;">
<?php
echo $row['pkey'];
?>
here is all my code...
Brandoe85 08-12-2008, 07:33 PM I guess I wasn't clear enough - put this in your code:
echo $queEmp;
Since that's the query that's failing, echo it out. Debug it. Post the result of the echo here.
abduraooft 08-13-2008, 07:25 AM Or have you echoed your variable echo $search-q2; ?
If I put echo $search-q2; the result is 0.
And, If I put echo $queEmp; i see a white page without results.
With PHP is possible to give a variable of another PHP file?
oh! I change $search-q2 for search_q2 because
"-" is not a valid character.
And, when I put echo $search_q2;. The result of echo is a white page without results.
abduraooft 08-13-2008, 01:30 PM Add
error_reporting(E_ALL);
ini_set('display_errors','On'); at the top of your page.
the result is:
Notice: Undefined variable: searchq in C:\Archivos de programa\Apache Group\Apache2\htdocs\jiramysql\lib\consultas.php on line 80
and the line 80 is:
echo $search_q2;
But... search_q2 is into another PHP. Not's defined...
abduraooft 08-13-2008, 01:50 PM Now, if <input name="search_q2" id="search_q2" type="text" ....../> is your input control, then change your search_incidencias.php like
<?php
if(isset($_GET['search_q2'])){
$searchq = strip_tags($_GET['search_q2']);
// use mysql_real_escape_string() (http://php.net/mysql_real_escape_string) to save your DB
$getRecord_sql = 'SELECT `pkey` FROM `jiraissue` WHERE project = "10040" and
`pkey` LIKE "%'.$searchq.'%"';
$getRecord = mysql_query($getRecord_sql) or die(mysql_error());
.................................
}//end of if
Good luck!
I have another problem.
in my index.php, in the input text, I insert value="hello!"
and I insert:
<?php
echo $search_q2;
?>
I don't have results! Is it normal?
|
|