Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1016799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:36:08+00:00 2026-05-16T10:36:08+00:00

I am trying to write to my database if a variable is equal to

  • 0

I am trying to write to my database if a variable is equal to 0. The problem is that it still writes to the database even when the variables equals 1. What is wrong??

echo $new_user;

if ($new_user == 0) {

  //SENT NEW USER WELCOME MESSAGE

  $adminid = '9';
  $welcomemessagetitle = 'Welcome to The site';
  $welcomemessagecontent = 'Hello and welcome';

  $addmessages = "INSERT into `user_messages`(`to_user`,`from_user`,`title`,`content`)
    VALUES ('$userid','$adminid','$welcomemessagetitle','$welcomemessagecontent');";

  $query = mysql_query($addmessages) or die(mysql_error());

  //SET USER AS NOT NEW USER

  $newuservalue = '1';

  $notnewuser = "UPDATE users SET new_user = $newuservalue WHERE id = $userid" ;

  $query2 = mysql_query($notnewuser) or die(mysql_error());

} elseif ($new_user == 1) {};

UPDATE FULL CODE::

<?php 
session_start();
include "../includes/db_connect.php";
///profile/index.php
if($_SESSION['id'])
{
  $username = $_SESSION['username'];
  $userid = $_SESSION['id'];
  //WRITE FIRST TIME LOGIN INFORMATION TO DATABASE
  $sql="SELECT new_user from `users` WHERE `id`= $userid ";
  $res=mysql_query($sql) or die(mysql_error());
  while($row=mysql_fetch_assoc($res)) $new_user = $row['new_user'] ;
  echo $new_user;
  if ($new_user == 0) {
    //SENT NEW USER WELCOME MESSAGE
    $adminid = '9';
    $welcomemessagetitle = 'Welcome to Escorvee';
    $welcomemessagecontent = 'Hello and welcome';
    $addmessages = "INSERT into `user_messages`(`to_user`,`from_user`,`title`,`content`)
      VALUES ('$userid','$adminid','$welcomemessagetitle','$welcomemessagecontent');";

     $query = mysql_query($addmessages) or die(mysql_error());
    //SET USER AS NOT NEW USER
    $newuservalue = '1';
    $notnewuser = "UPDATE users SET new_user = $newuservalue WHERE id = $userid" ;
    $query2 = mysql_query($notnewuser) or die(mysql_error());
  } elseif ($new_user == 1) {};
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:36:09+00:00Added an answer on May 16, 2026 at 10:36 am

    It the variable $new_user is the value 1 then your code won’t be executed so I would guess one of the following applies:

    • $new_user isn’t 1.
    • The database is being modified from another location.
    • Your script is being called twice.

    To work out which you will have to provide more information in your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a plugin that defines a MongoMapper model. The problem is
I am trying to write a program that uses a Berkeley Database and i
I am trying to write some variable data back to a database table when
I'm trying to write a application that sends user's geolocation to MYSQL database every
I'm trying to write a trigger that deals with the following problem . I'm
I'm trying to write an IPN that, upon successful transaction, modifies a database entry
I am trying to write a function that connects to a database and returns
I am trying to write three variables into a database table. The code I
I'm trying to write some code for my database to enable a dropdown box
Overview: Trying to write a trigger for a SQL Server 2008 database. TableA and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.