spanienfoeck Posted October 3, 2006 Share Posted October 3, 2006 i want to prove if the entry allready exists... as long as there are not all fields the same it should do a new entry in the db...can someone help me please????cheers[code]$query="SELECT nombre, ultimocontacto, esde, vivido, conoces, asunto, anuncio, email, otraforma,pais FROM db2006_tmp WHERE nombre='$nombre'AND ultimocontacto='$ultimocontacto'AND esde='$esde'AND vivido='$vivido'AND conoces='$conoces'AND asunto='$asunto'AND anuncio='$anuncio'AND email='$email'AND otraforma='$otraforma'AND pais='$pais'"; $res =mysql_query($query); $found = mysql_num_rows($res); mysql_query(""); if ($found == 0) { mysql_query("INSERT INTO db2006 (nombre, ultimocontacto, esde, vivido, conoces, asunto, anuncio, email, otraforma, timestamp, pais) values ('$nombre','$ultimocontacto','$esde','$vivido','$conoces','$asunto', '$anuncio','$email','$otraforma','$timestamp','$pais');"); print "OK, saved...";} else { print "allready in list";}[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 3, 2006 Share Posted October 3, 2006 You don't say why you think there is a problem, but you have an extra call the mysql_query.Here's how I would write your code:[code]<?php$query="SELECT * FROM db2006_tmp WHERE nombre='$nombre'AND ultimocontacto='$ultimocontacto'AND esde='$esde'AND vivido='$vivido'AND conoces='$conoces'AND asunto='$asunto'AND anuncio='$anuncio'AND email='$email'AND otraforma='$otraforma'AND pais='$pais'";$q2 = "INSERT INTO db2006 (nombre, ultimocontacto, esde, vivido, conoces, asunto, anuncio, email, otraforma, timestamp, pais) values ('$nombre','$ultimocontacto','$esde','$vivido','$conoces','$asunto', '$anuncio','$email','$otraforma','$timestamp','$pais')";$res = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());$found = mysql_num_rows($res);if ($found == 0) { $r2 = mysql_query($q2) or die("Problem with insert, query: $q2<br>" . mysql_error()); echo "OK, saved...";}else echo "allready in list";?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
spanienfoeck Posted October 3, 2006 Author Share Posted October 3, 2006 thx, i'll try it.the problem is, that it doesn't do what i want :-) like, if i press the verifylink, the program should prove if the same entry is allready in the .tmp database, if not it should write it in the maindatabase and delete the .tmpdatabase entry...you get the idea? very simple....but with my old code i got sometimes an entry in the .tmpdatabase, but most times i don't get any entry in none of the databases, and sometimes i got the same entry all the time... i doesn't prove if the same entry is allready in the database. cheers Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 3, 2006 Share Posted October 3, 2006 Can we see the code of what you're describing?Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.