views:

87

answers:

3

this script have to update things on every refresh but not working. lend me a hand

$yp = mysql_query("select id from yyy where twitterid = '$tid'");

$qq = "update yyy set twitterid = '$tid', 
twitterkullanici = '$twk', 
tweetsayisi = '$tws', 
takipettigi = '$tkpettigi', 
takipeden = '$tkpeden', 
nerden = '$nerden', 
bio = '" . mysql_real_escape_string($bio) . "', 
profilresmi ='$img', 
ismi = '$isim' 
where id = '$yp'";
$xx = mysql_query($qq);
A: 

To make debugging SQL easier in PHP add the following after to your mysql_query(0 call.

mysql_query($qq) or die("A MySQL error has occurred.<br />Your Query: " . $qq. "<br /> Error: (" . mysql_errno() . ") " . mysql_error())

Just make sure you remove it before you go into prod, as it can give useful info away to any hackers attempting Sql Injection.

Matt
+2  A: 

$yp - is a result of mysql_query (resource). You have to read id from database (mysql_fetch_array or mysql_fetch_row).

$yp = mysql_query("select id from yyy where twitterid = '$tid'");
if ($yp)
{
   if ($row = mysql_fetch_array($yp,MYSQL_ASSOC))
   $id = $row["id"];
}

Now use $id in WHERE clause.

a1ex07
That will be it. Need to extract the id from the resource.
Matt
+3  A: 

Looks like you are not getting the value out of the variable $yp.

You need to do

$row = mysql_fetch_row($yp);

then

id = '.$row[0] .'

in your update query

adam
thank you for answer :)
Ronnie Chester Lynwood
anytime glad I could help!
adam