w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to check if ID exists in database, otherwise insert it into database?
if you don't want to use autoincrement field, you can change your query in this way: SELECT id FROM students WHERE id = ? limit 1 becames SELECT count(id) FROM students WHERE id = ? So you can check if the result is > 0 (exists) or not (not exists)

Categories : PHP

Check in database if it exists or not
You need to pass listOfFiles in public void execute() method like: public void execute(File[] listOfFiles){ } That is why you are getting compilation error as listOfFiles can not be resolved to variable. Or you need to declare the variable listOfFiles into the class level. Edit: (Not able to understand from where you are calling execute) int i = 0;//Declare i to class level. public void execute(File[] listOfFiles) { if (listOfFiles[i].isFile()) { String fileName = listOfFiles[i].getName(); System.out.println(fileName); doesFileExistInDb(fileName); i++; } }

Categories : Java

How do I check database for a value that already exists?
See mysql_num_rows. You should also look into using PDO or MySQLi http://php.net/manual/en/function.mysql-num-rows.php if (mysql_num_rows($query) > 0) { echo "user already exists"; }

Categories : PHP

Check if a database exists
You shouldn't have to catch the exception, the return type returns an JET_ERR type that will let you know if there is a problem, if you are looking for a simple bool check, I believe you may be out of luck, or have to write your own. Source : http://msdn.microsoft.com/en-us/library/gg294074.aspx http://msdn.microsoft.com/en-us/library/gg294092.aspx const JET_errSuccess = 0; result = JetCreateDatabase(...); if(result != JET_errSuccess) { //throw error }

Categories : C#

How do I check if the value already exists in the database?
I need to insert certain data into my database through the form. But before that, it needs to be checked whether the value that's been typed in the txtField already exists in the database. No. You need to insert it into the database if it isn't already there. The correct way to do that is to try the insert and catch the failure. Otherwise you are creating a timing-window problem between your check and your insert, during which another client could do the insert.

Categories : Java

Check if user exists in database
you need to use this code after prepare statement $stmt->execute(); $stmt->store_result(); put this if ($result->num_rows > 0) { echo "email exisits!"; } instead of if ($result->num_rows) { echo "email exisits!"; }

Categories : PHP

Check if table exists in database
create a sample table in the database with coloumns you want Here sample table is chatsample create procedure [dbo].[new_table](@tbName varchar(50)) as begin declare @Sql nvarchar(max) set @Sql='if NOT EXISTS(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'''+@tbName+''') AND type in (N''U''))' + CHAR(10) + 'begin' + CHAR(10) + 'select * into '+ @tbName+ ' from ChatSample'+CHAR(10)+ 'end'+Char(10) exec(@Sql) end

Categories : SQL

php check if a username exists in a database
you have error here if(isset($_POST))['username'])){ it should be if(isset($_POST['username'])){ $_POST['username'] should be enclosed inside isset function

Categories : PHP

How do I check if a user name already exists in Database
"SELECT FName FROM Users WHERE FName = @paramUsername" and then you insert the parameter into the cmd like so: cmd.Parameters.Add("paramUsername", System.Data.SqlDbType.VarChar); cmd.Parameters["paramUsername"].Value = "Theusernameyouarelookingfor";

Categories : C#

Check whether directory exists "rel1.5" exists in Repository https://xx/svn/MobileApp/Tags if exists do some action else the other
<project name="demo" default="build"> <property name="tag" value="rel1.5"/> <condition property="url.exists"> <http url=" https://www.exampledomain.com/svn/MobileApp/Tags/${tag}" errorsBeginAt="401"/> </condition> <target name="check1" if="url.exists"> <echo message="URL exists"/> </target> <target name="check2" unless="url.exists"> <echo message="URL does not exist"/> </target> <target name="build" depends="check1,check2"> </target> </project>

Categories : Svn

Check if a username and email already exists in my database
First a great tip. the mysql functions in PHP is out of date you should read something about PDO. But for now add this before your insert query. if(mysql_num_rows(mysql_query("SELECT ID FROM users WHERE email = '". mysql_real_escape_string($email) ."')) != 0) { exit("email exists"); }

Categories : PHP

How to check if string a exists in a specified column in database
Try doing this. Dim user = Me.WSDataSet.users.FindByUserName(IDtxt.Text) If not user is nothing Then 'Do what you want with the user object Else 'Message User does not exist. End If you just check if the user exists then do what you want with it.

Categories : Database

Check if cell number exists in database
I see your post url is: url:"formpost" if js code and the php in the same file, the return data of ajax will be whole html and javascript instead of just "echo $find;"; of course your data will never be 0;

Categories : PHP

Check if user already exists in MySql Database with C#
You can create a Unique Constraint on the username field in the database, this will throw an exception if the user already exists. Alternatively, you do a manual select from the table and see if there is a user with the same name before insertion.

Categories : C#

check if email already exists in database jquery +php
You are comparing the username with the email address. Is this how your DB works? $sql = "SELECT * FROM users WHERE username='".$email."'"; I bet you have a field in your database for the email itself, otherwise i suggest you do this. The query should look like this: $sql = "SELECT * FROM users WHERE email = '".$email."'"; Without the single quotes for the column.

Categories : PHP

How to check if the database exists or not in rails before doing a rake db:setup
Here are some bash scripts I made for this purpose: Postgres if echo "c $PGDATABASE; dt" | psql | grep schema_migrations 2>&1 >/dev/null then bundle exec rake db:migrate else bundle exec rake db:setup fi Mysql if echo "use $MYSQLDATABASE; show tables" | mysql | grep schema_migrations 2>&1 > /dev/null then bundle exec rake db:migrate else bundle exec rake db:setup fi These check for the presence of the schema_migrations table to determine whether rake db:setup has been run previously.

Categories : Ruby On Rails

Check if row exists in database table not working php mysql
if($Username!="" && $Password!="") { $checkusername = mysql_query("SELECT * FROM members WHERE username='$username'"); Variables are case sensitive, $username should be $Username in your select. Make sure to properly escape the value of $Username and $Password before inserting them into SQL strings like this or you may cause an SQL injection problem. Even better, use MySQLi or PDO to get real parameterised queries.

Categories : PHP

Laravel 4: how do I check if a database entry already exists against my store function
Easy - you want the Unique validation rule Add this to your rules array('url' => 'unique:posts'),

Categories : PHP

Check if the user name is entered in EditText already exists in the SQL database. - Android
for (c.moveToFirst(); c.isAfterLast(); c.moveToNext()){ I think should be for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){ Do you only want one name to come back from this? At the moment you are looping, but resetting the lectura value every time. You can use lecture += c.getString(nom) + ' '; If there are going to be lots of Strings, you might want to use a String builder. public String obtenerNombresDeUsuario() { Cursor c = db.query(TABLA_BASEDATOS, new String[] {KEY_NOMBRE, }, null, null, null, null, null); int nom = c.getColumnIndex(KEY_NOMBRE); StringBuilder lectura = new StringBuilder(); for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){ lectura.append(c.getString(nom) + ' '); } return lectura.toString(); } You can al

Categories : Android

How to check if a value already exists to avoid duplicates?If it exist then do nothing otherwise insert record into database
You can do that with the following code: <?php if($stmt = $db->prepare("SELECT * FROM tablename WHERE id=?")){ $stmt->bind_param('i', $id); $stmt->execute(); $stmt->store_result(); if($stmt->num_rows == 0){ // CREATE RECORD } } ?> You just need to search in the table and check if the query returns something

Categories : PHP

Resolved: How to check multiple email addresses in dynamic fields to check if user already exists or not
I dont think your IF-Statement in your PHP-Code is executed. You're checking for an email-parameter, but your ajax-data looks like data: "name="+ name Try to change it to data: { email: name },

Categories : Javascript

AngularJs -.net MVC WebApi Authentication example
If you put a cookie in the header on server side AngularJS will send this cookie all time.. U have nothing to do. If you want to pass the token in Header not in cxookie on Angular side just do this : $httpProvider.defaults.headers.common['X-Auth'] = yourKey; in your config block. Then if you want to know if the user is logged or if he's got the rights just implements an interceptor. It's a simple factory that you'll push in responseIntercetors always in your config block. This factory will listen each response from the server and on his implementation you'll check the status code of the response in error case : 401 --> not logged 403 --> not authorize example of factory : myModule.factory('myHttpInterceptor', function ($q) { return function (promise) { return promise.th

Categories : Authentication

In C check to see if an int exists?
The array elements may not be initialized with zero always. The first thing you need to do is initialize it with a default value. say 0 or -1 or whatever. Then you can modify your code as follows: int *spaceCheck; int i, Value; for(i=0;i<169;i++){ spaceCheck = &Array[i]; if(*spaceCheck!=default_value){ continue; else //do this job } Note that you were also storing the reference of the array element. If you want to check its data you need to use the dereferencing operator *. Hope that this is what you want. Simpler way to write the above code is to not use pointers at all. It is as follows: int i, Value; for(i=0;i<169;i++){ if(Array[i]!=default_value){ continue; else //do this job }

Categories : C

Updating a complex object in a database via WebAPI Controller, theorycrafting
I think you should be using a PUT/PATCH method; however, I am assuming that you want to update entities, not create them. Using Put/Patch would help to make your application RESTful. REST is a very popular model for web api's EDIT : For reference POST is CREATE, GET is READ, PUT/PATCH is UPDATE, DELETE is DELETE That is the making of CRUD to RESTful Web Api's in general

Categories : C#

How to check if a json key exists?
use optString instead of getString: Returns the value mapped by name if it exists, coercing it if necessary. Returns the empty string if no such mapping exists

Categories : Java

check if the value already exists in vector
Using find_if and lambda filter: auto match = std::find_if(CollectionOfYears.begin(), CollectionOfYears.end(), [&year](v){ return year == v.last(); }) if (match == CollectionOfYears.end()){ //no value previously } This still iterates the whole array. If you need more efficient search you should keep the array sorted and use binary search or std::set. Note that vector::end() returns iterator to the element after the last element. This is why std::find ignores the last value (because it is already out of bounds!).

Categories : C++

Check whether value exists in SQL table
There's a lot of unclear things in the question, but I suspect the biggest question here is whether TagID is a numeric type vs a string type. But there's also the big question of why it is going into a data-set. But; getting back to the actual question - checking if a value exists; I would do something like (using dapper to make correct parameterization simple): // where tagNo is a local variable... int? id = connection.Query<int?>( "select Id from Student where TagID=@tagNo", new { tagNo } ).FirstOrDefault(); if(id == null) { // doesn't exist } else { // exists, plus you now know the id - it is: id.Value } But ultimately, if your original code worked in a DataSet, it should continue working - if it isn't, I suspect you have simply messed up the schema (maybe a column

Categories : C#

How to check url exists or not on wp7 apps?
You use something like this. bool result = false; using (WebClient client = new WebClient()) { try { Stream stream = client.OpenRead(url); if (stream != null) { result = true; } else { result = false; } } catch { //Any exception will returns false. result = false; } } return result; As you are using WP7, you may need to look the async versions. Source : http://www.dotnetthoughts.net/how-to-check-remote-file-exists-using-c/

Categories : C#

How to check if a registry key exists
You need to call ValueExists rather than KeyExists. A key is what appears as a folder in Regedit but you are looking for a value named nginx.exe in the key HKCUSoftware...Run. Some other comments: Since you are only reading from the registry, use OpenKeyReadOnly rather than OpenKey. Check the return value of OpenKeyReadOnly in case the key cannot be opened. If you actually need to do this with HKLM (as you state in a comment), watch out for registry redirection confusion when running 32 bit process on 64 bit system.

Categories : Delphi

Call to DB to check if a value exists
Here, code is not an integer value. Hence, enclose it by single quotes. You should also include the $conn (connection variable) while using mysqli_query() statement - mysqli_query() $codeCheck = mysqli_query($conn, "SELECT code FROM discount WHERE code = '$discountCode'"); [EDIT] If you are including the connection page inside this page, try doing these: connect.php function connect(){ $conn = mysqli_connect($host, $un, $pw, $db); return $conn; } Now, call this function from the current page and get the connection variable: $conn = connect(); Now, use $conn for the mysqli_query() function. Change the if condition as follows: if(isset($_POST['discount']))

Categories : PHP

How to check if file name already exists?
The File class provides the exists() method, which returns true if the file exists. File f = new File(newFileName); if(f.exists()) { /* show alert */ }

Categories : Java

C++ Check if file exists
So, assuming it's OK to simply check that the file with the right name EXISTS in the same directory: #include <fstream> ... void check_if_dll_exists() { std::ifstream dllfile(".\myname.dll", std::ios::binary); if (!dllfile) { ... DLL doesn't exist... } } If you want to know that it's ACTUALLY a real DLL (rather than someone opening a command prompt and doing type NUL: > myname.dll to create an empty file), you can use: HMODULE dll = LoadLibrary(".\myname.dll"); if (!dll) { ... dll doesn't exist or isn't a real dll.... } else { FreeLibrary(dll); }

Categories : C++

Check Key Exists in Array
How about instead of pushing the results to an array you push them to an object like so: var officeLines = [{"Office":"abc", "Name":"ABC", "Total":0}, {"Office":"def", "Name":"DEF", "Total":11}, {"Office":"def", "Name":"DEF", "Total":1}, {"Office":"ghi", "Name":"GHI", "Total":1111}]; var offices = {}; ko.utils.arrayForEach(officeLines, function (item, indx) { var office = item.Office; if (!offices[office]) { offices[office] = 1; } else { offices[office]++; } }); document.write(JSON.stringify(offices)); // -> {"abc":1,"def":2,"ghi":1} http://jsfiddle.net/zd5Db/

Categories : Javascript

How do i check if a "Thread" is already exists?
You can use a pattern like this to ensure that if this particular method is started in a new thread pool thread it will do nothing if a previous instance is already running. class Foo { //make static if this is called from different instances and should still //be synchronized private int isRunning = 0; public void DoStuff() { if (Interlocked.Exchange(ref isRunning, 1) == 0) { try { DoRealStuff(); } finally { Interlocked.Exchange(ref isRunning, 0); } } } }

Categories : C#

Check if a row with given values exists
You could select the count to see if a record exists already SELECT count(*) FROM following WHERE idUser = <id> AND followingID = <followingId> If the count is greater than zero, then a relationship exists.

Categories : PHP

PHP check if url parameter exists
Use isset() if(isset($_GET["id"]) && trim($_GET["id"]) == 'link1'){ $slide = trim($_GET["id"]); } else{ $slide = ''; }

Categories : PHP

Recurring job to check if url exists
Writing and running a simple link checker is easy. Doing that for 1000s of links quickly, without redundancy, and handling dead and slow-responding links without bogging down your entire system gets harder. I'd use three threads, plus two queues: A dispatcher thread that only reads from the database. It is responsible for finding and queuing URLs to be checked in to a "to be checked" queue. A worker thread that consumes from the first queue and pushes results into the "updated URL results" queue. An updater/consumer thread that takes the result of a thread in #2 and updates the database. Ruby has some built-in classes to help: Thread Queue I'd highly recommend Typhoeus and Hydra for use in the middle thread. The documentation for these two classes cover a lot of what you need t

Categories : Ruby On Rails

How to check if a subdomain exists
DownloadStringAsync is exactly that – asynchronous. It only finishes some time after your code finishes running. To see the result or error, handle the DownloadStringCompleted event.

Categories : Vb.Net

Check to see if row exists before adding it?
You need to select only one record : IPACS_Certification doesExist = db.IPACS_Certification.Where(m => m.adUserName == item && m.procedureID == procedureID).Select(m => m).FirstOrDefault();

Categories : C#

How to check if a key exists in a MemoryCache
Use bool Contains(string key, string regionName) method. MSDN: Determines whether a cache entry exists in the cache. Return Value Type: System.Boolean true if the cache contains a cache entry whose key matches key; otherwise, false. (http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.contains.aspx)

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.