> Why i can't tranfer data from one table to another with this code? I
can't
> pass "$reg" to $c and $t... : \
> thanks
> 
> <?
>  $ligacao=mysql_connect("localhost","","") or die (mysql_error());
>  $real="INSERT INTO divx (titulo,cds) VALUES ('$t','$c')";

move the above line...

>  $temp="SELECT * FROM divxtemp";
>  //$num=mysql_affected_rows();
>  $restemp=mysql_db_query("DB_nac31915",$temp) or die (mysql_error());
>  if ($ligacao)
>  {
>   while($reg=mysql_fetch_array($restemp))
>   {
>    $t=$reg["titulo"];
>    $c=$reg["cds"];

to here...

>    mysql_db_query("DB_nac31915",$real) or die (mysql_error());
>   }
>  }
>   mysql_close();
> ?>

The problem you're having is that $t and $c are evaluated when you
assign that string to $real, NOT when it's used in mysql_db_query().
Since they are empty at that time, you're creating a SQL statement
that's ... VALUES ('','') and executing it every time.

Also, the mysql_db_query() function is depreciated. You'll have to use
mysql_select_db() to select the database you want to use, then use
mysql_query() to issue your queries. 

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to