views:

44

answers:

2

got this:

if (mysql_num_rows($ak) == 0) {
    $sonuc = mysql_query($sql) or die(mysql_error());
}
elseif (mysql_num_rows($ak) == 1) {
    $sonuc = "you already added";
}

this script works succesfully. but mysql_query($sql) echos "1" how can let it echo "successfully added." thanks...

(im asking simple questions because im new to php)

+2  A: 
$sonuc = mysql_query($sql) or die(mysql_error());
if($sonuc) {
   echo "successfully added.";
}

But as you have or die(mysql_error()) this is also valid (but easier to mess up with when you change code):

$sonuc = mysql_query($sql) or die(mysql_error());
echo "successfully added.";
Felix Kling
kk fixed added ; to end of echo
Ronnie Chester Lynwood
Yeah well I missed the `;` at the end of the line.... too much Python ;)
Felix Kling
Add a semicolon to the end of the echo line.
Chris Gutierrez
thank you works superb.
Ronnie Chester Lynwood
A: 

Try this:

if (mysql_num_rows($ak) == 0) {
    $ak = mysql_query($sql) or die(mysql_error());
    $sonuc = "successfully added";
}
elseif (mysql_num_rows($ak) == 1) {
    $sonuc = "you already added";
}

echo $sonuc;
Sarfraz