Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Join Date
    Dec 2008
    Posts
    30

    Unanswered: Php mysql help me '

    Hello
    Can you help me , i need delete and send the values 'code ' after validated to another tables .
    delete from jos_call and move them to jos_call1

    Code:
    <?php
    
    
    $mysql_host="xxxxxxxxxxx";
    $mysql_user="xxxxxxxxxx";
    $mysql_password="xxxxxxxxxx";
    $mysql_db = "xxxxxxxxx"; 
    
    
    $conn = mysql_connect("$mysql_host","$mysql_user","$mysql_password")or die("Could not connect : " . mysql_error());
    mysql_select_db("$mysql_db",$conn) or die("Select database failed"); 
    
    
    $var=@$_REQUEST['nombre']."'";
    $query= mysql_query("Select * from jos_call where code = '".$var,@$conn);
    if (mysql_num_rows($query) == 0 )  {
    echo @$_REQUEST['nombre'].'  Su codigo 6 digitos.Codigo no valido.';
    }else{
    echo @$_REQUEST['nombre'].'  Codigo correcto!  ' ;
    }
    
    something  here....
    
    mysql_close($conn);
    
    ?>

  2. #2
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Quote Originally Posted by maxbox
    Hello
    Can you help me , i need delete and send the values 'code ' after validated to another tables .
    delete from jos_call and move them to jos_call1
    What exactly do you mean by send the values code to another table?

  3. #3
    Join Date
    Dec 2008
    Posts
    30

    explain

    I need to insert results from table1 jos_call field code into table2 jos_call1 field code then delete values in the table1 jos_call field code.

    If the numbers found in the tables jos_call field code when the user typed the numbers in the text field the user can submit the form text but this numbers or code must be valid only one time per user. So i need remove this code from tables1 and insert this in another tables2 .

  4. #4
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Well, there may be a better way to handle the sql part of your problem but to copy a row from one table to another, you might want to do something like this:
    insert into table(col1,col2,col3,col4) select (col1,col2,col3,col4) from table where condition
    I looked to see if there was a mysql command that would copy and delete but I was not able to find such an animal.

    As for the php, you will have to query once to copy the row from table 1 to table 2 and then query again to delete the row from table 1. Before you delete the row from table 1, I would recommend that you check to make sure that the row was successfully copied over first.

    So you may want to do something like:

    PHP Code:
    $querymysql_query("insert into table(col1,col2,col3,col4)select(col1,col2,col3,col4)".$var,@$conn);

    $querymysql_query("DELETE FROM table1 WHERE ...".$var,@$conn); 
    I hope this helps you.

  5. #5
    Join Date
    Dec 2008
    Posts
    30

    error

    i have tryed with this but i have received 500 internal server error



    Code:
    <?php
    $mysql_host="xxxxxxxxxx";
    $mysql_user="xxxxxx";
    $mysql_password="xxxxxxxx";
    $mysql_db = "xxxxxxxxx"; 
    
    
    $conn = mysql_connect("$mysql_host","$mysql_user","$mysql_password")or die("Could not connect : " . mysql_error());
    mysql_select_db("$mysql_db",$conn) or die("Select database failed"); 
    
    
    $var=@$_REQUEST['nombre']."'";
    $query= mysql_query("Select * from jos_call where code = '".$var,@$conn);
    if (mysql_num_rows($query) == 0 )  {
    echo @$_REQUEST['nombre'].'  Su codigo 6 digitos.Codigo no valido.';
    }else{
    echo @$_REQUEST['nombre'].'  Codigo correcto! ' ;
    }
    else{
    $query= mysql_query("INSERT INTO jos_call1 where code = '".$query,@$conn);
    $query= mysql_query("delete from jos_call where code = '".$query,@$conn);
    }
    }
    mysql_close($conn);
    
    ?>

  6. #6
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Post the whole error message from your error log please

  7. #7
    Join Date
    Dec 2008
    Posts
    30

    error log

    <b>Parse error</b>: syntax error, unexpected T_ELSE in <b>/xxx/xxxxxxxxx/public_html

    /xxxxxxx/comprueba.php</b> on line <b>21</b><br />

  8. #8
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Ok, get rid of the last brace "}" above the mysql_close(). You have placed one too many in there.

    You also have an error that I see in your code:

    PHP Code:
    '".$query,@$conn);
    ^^--------------------------These are incorrect 
    You will need to finish them on the other side to concatenate.

  9. #9
    Join Date
    Dec 2008
    Posts
    30

    error again

    i have change with this and the error is now:

    Parse error: syntax error, unexpected T_STRING in /xxxxxx/comprueba.php on line 23




    Code:
    echo @$_REQUEST['nombre'].'  Codigo correcto! ' ;
    }
    {
    $query=mysql_query("INSERT INTO jos_call1 where code = .$query,@$conn);
    $query=mysql_query("delete from jos_call where code = .$query,@$conn)or die("Could not connect : " . mysql_error());
    }
    
    mysql_close($conn);
    
    ?>

  10. #10
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Try this:
    PHP Code:
    $query=mysql_query("INSERT INTO jos_call1 where code = '$query'",@$conn);
    $query=mysql_query("delete from jos_call where code = '$query'",@$conn)or die("Could not connect : " mysql_error()); 

  11. #11
    Join Date
    Dec 2008
    Posts
    30

    error again

    I cant resolved this


    Su codigo 6 digitos.Codigo no valido.
    Warning: mysql_query() [http://www.mysql.com/doc]: 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 'where code = 'Resource id #2'' at line 1 in /xxxxxxxxxx/comprueba.php on line 22

  12. #12
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Ok, that's actually progress.

    Your error is now coming from mysql. Please post ALL of your code.

  13. #13
    Join Date
    Dec 2008
    Posts
    30

    Here is the code

    Here is the code
    error:
    Su codigo 6 digitos.Codigo no valido.
    Warning: mysql_query() [http://www.mysql.com/doc]: 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 'where code = 'Resource id #2'' at line 1 in /xxxxxxxx/comprueba.php on line 22


    Code:
    <?php
    
    $mysql_host="xxxxxxx";
    $mysql_user="xxxxx";
    $mysql_password="xxxx";
    $mysql_db = "xxxxx"; 
    
    
    $conn = mysql_connect("$mysql_host","$mysql_user","$mysql_password")or die("Could not connect : " . mysql_error());
    mysql_select_db("$mysql_db",$conn) or die("Select database failed"); 
    
    
    $var=@$_REQUEST['nombre']."'";
    $query= mysql_query("Select * from jos_call where code = '".$var,@$conn);
    if (mysql_num_rows($query) == 0 )  {
    echo @$_REQUEST['nombre'].'  Su codigo 6 digitos.Codigo no valido.';
    }else{
    echo @$_REQUEST['nombre'].'  Codigo correcto! ' ;
    }
    {
    $query=mysql_query("INSERT INTO jos_call1 where code = '$query' ",@$conn);
    $query=mysql_query("delete from jos_call where code = '$query'",@$conn)or die("Could not connect : " . mysql_error()); 
    }
    
    mysql_close($conn);
    
    ?>
    Last edited by maxbox; 01-02-09 at 17:08.

  14. #14
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    why would you want to move values from one table to another table? it doesn't sound right to me.
    I'd rather be riding on the Tiger 800 or the Norton

  15. #15
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Quote Originally Posted by maxbox
    Here is the code
    error:
    Su codigo 6 digitos.Codigo no valido.
    Warning: mysql_query() [http://www.mysql.com/doc]: 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 'where code = 'Resource id #2'' at line 1 in /xxxxxxxx/comprueba.php on line 22


    Code:
    <?php
    
    $mysql_host="maxbox.ipowermysql.com";
    $mysql_user="anuncios";
    $mysql_password="ganaras4";
    $mysql_db = "suecia"; 
    
    
    $conn = mysql_connect("$mysql_host","$mysql_user","$mysql_password")or die("Could not connect : " . mysql_error());
    mysql_select_db("$mysql_db",$conn) or die("Select database failed"); 
    
    
    $var=@$_REQUEST['nombre']."'";
    $query= mysql_query("Select * from jos_call where code = '".$var,@$conn);
    if (mysql_num_rows($query) == 0 )  {
    echo @$_REQUEST['nombre'].'  Su codigo 6 digitos.Codigo no valido.';
    }else{
    echo @$_REQUEST['nombre'].'  Codigo correcto! ' ;
    }
    {
    $query=mysql_query("INSERT INTO jos_call1 where code = '$query' ",@$conn);
    $query=mysql_query("delete from jos_call where code = '$query'",@$conn)or die("Could not connect : " . mysql_error()); 
    }
    
    mysql_close($conn);
    
    ?>
    Ok, line 22 is your last mysql $query where you are doing the delete from. Look at that line carefully and see if you can pick out why you are getting the database error. Here is a hint:

    How many $query variables are you using in this code? What is the $query on line 22 referring to?


Posting Permissions

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