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 4566764
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:50:04+00:00 2026-05-21T18:50:04+00:00

This may be a stupid question but I might aswell as it :) is

  • 0

This may be a stupid question but I might aswell as it 🙂

is there away to force

$tel1 = '05';// string
settype($tel1,'string');
$tel1 = 06;//either throw error, or convert it to string automatically.
var_dump($tel1);//(string [2]) 05

The above code is of the top of my head so might not be accurate but I need to keep a variable as a string not numeric, because of some silly thing I have done, now my phone numbers lose the leading 0s 🙁

n I cn’t rewrite it because it will mess up with other numeric types,b4 u ask it was an automated service for db to check if it was a numeric value or not,

UPDATE
This is the problem

function escape($str){
   if(is_numeric($str)){
       return $str;
   }else{
       return "'".mysql_real_escape_string($str).'\'';
   }
}
$tel1 = "06";
$sql = 'SELECT * FROM blabla WHERE id = '.escape($tel1).'';
//above is same as below
$sql = 'SELECT * FROM blabla WHERE id = 06 ';

I can’t change anything inside the scape function because other inputes thruout the website are using this function, I dont wanna mess their validations.

  • 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-21T18:50:05+00:00Added an answer on May 21, 2026 at 6:50 pm

    Your use of is_numeric tests for numeric content, not an integer type. But then you take a variable called $str which implies you want it to be a string.

    Perhaps use:

    function escape($val) {
       if (is_numeric($val) && !is_string($val)) {
           return $val;
       }
       else{
           return "'" . mysql_real_escape_string($val) . '\'';
       }
    }
    

    Now strings will be escaped and quoted, but not if they contain only numeric content.

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

Sidebar

Related Questions

this may seem like a stupid question but I have a query string which
This may be a stupid question but im just starting to learn Rail thats
this may be a stupid question but when I add a reference to my
I'm not a DBA so this may be a stupid question but I'll ask
This may sound like a stupid question but I'm a beginner not just to
This may sounds like a stupid question but can't find anything on google, probably
This may be a stupid question, but I have to ask! I have the
This may be a stupid question to ask, but still I need to know
This may seem like a stupid question, but what message do i send to
This may sound like a stupid question, perhaps it is. But I'm only trying

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.