Jump to content
php.lv forumi

IF ELSE ELSEIF


FT3

Recommended Posts

a nevar vienkarshi insert ignore ?

bet nu ..

 


$query = mysql_fetch_object(mysql_query("select count(id) as cnt from tabula where homepage='http://www.php.lv'"));
if($query->cnt == 0){
mysql_query("insert into table (homepage,ip) values('http://www.php.lv','127.0.0.1')");
}

Edited by EdgarsA
Link to comment
Share on other sites

$adress = $_SERVER['HTTP_HOST'];
$link = $_SERVER['PHP_SELF'];


$query = mysq_fetch_object(mysql_query("select count(id) as cnt from clients where adress='$adress'"));
if($query->cnt == 0){
mysql_query("insert into clients (adress,link) values ('$adress','$link')");
}

 

Fatal error: Call to undefined function mysq_fetch_object()
Link to comment
Share on other sites

$adress = $_SERVER['HTTP_HOST'];
$link = $_SERVER['PHP_SELF'];


$query = mysq_fetch_object(mysql_query("select count(id) as cnt from clients where adress='$adress'"));
if($query->cnt == 0){
mysql_query("insert into clients (adress,link) values ('$adress','$link')");
}

 

 

 

ak dievs.. ak dievs.. bērniņ mīļo, ēd tak no rokām...

cerēju jau ka pats tiksi galā ar šo.

Link to comment
Share on other sites

Varbūt šādi...

 

$jau_ir=mysql_fetch_array(mysql_query("SELECT * FROM clients WHERE adress=$adress OR link=$link"));
if (!$jau_ir){
mysql_query("INSERT INTO clients(adress,link) VALUES('$adress','$link')"); 
} else {
echo"Šāds lauks jau eksistē !";
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...