Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    make a query with the value of text

    hi!

    I have problems to give the value of a text.

    I have in a PHP this:

    Code:
    <?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:

    Code:
    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

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Echo out your sql statement for debugging. What do you get?

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Echo it like this.

    Code:
    $descript = $rowEmp["description"];
    echo "$descript";

  • #5
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    I meant echo $queEmp and debug it.

  • #6
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    $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
    Code:
    echo $queEmp	= "select pkey, created, UPDATED, repor...........
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #8
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $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...

  • #9
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is the text box into a index.php:

    Code:
    <input name="search-q2" id="search-q2" type="text" onkeyup="javascript:autosuggest2()"/>
    and into the consultas.php, the case E:

    Code:
    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:

    Code:
    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:

    Code:
    <?php
    $searchq		=	strip_tags($_GET['q']);
    $getRecord_sql = 'SELECT `pkey` FROM `jiraissue` WHERE project = "10040" and `pkey` LIKE "&#37;'.$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...
    Last edited by guif; 08-12-2008 at 04:54 PM.

  • #10
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    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.

  • #11
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Or have you echoed your variable echo $search-q2; ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #12
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #13
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by guif; 08-13-2008 at 01:24 PM.

  • #14
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Add
    PHP Code:
    error_reporting(E_ALL);
    ini_set('display_errors','On'); 
    at the top of your page.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #15
    New Coder
    Join Date
    Jul 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •