Jump to content

Recommended Posts

im trying to add another error level to this query but i can not figure out were to put it. if i put it in the obvious place i can not see how the syntax would work.

 

original code

$sql="select * from spl WHERE spl1 LIKE ('%$search%') LIMIT 1";
$result=mysql_query($sql) or die (mysql_error());
$rows=mysql_fetch_array($result);
$passon=$rows['orsku'];


//2nd 
$sql1="select * from dsgi WHERE reconsku LIKE '%$passon%'";
$result1=mysql_query($sql1) or die (mysql_error());

 

this is how i "think" it should be

 

// 1st query
$sql="select * from spl WHERE spl1 LIKE ('%$search%') LIMIT 1";
$result=mysql_query($sql) or die (mysql_error());
$rows=mysql_fetch_array($result);
$passon=$rows['orsku'];

//added code 
$pattern = '([^0-9])' ;       
if(preg_match($rows['orsku']))
{
echo “The data must consist only of numeric characters." ;
}


//2nd 
$sql1="select * from dsgi WHERE reconsku LIKE '%$passon%'";
$result1=mysql_query($sql1) or die (mysql_error());

 

 

basicly the var that is being passed between tables must be a number else return error

 

Link to comment
https://forums.phpfreaks.com/topic/202026-error-level/
Share on other sites

You could just use:

 

// 1st query
$sql="select * from spl WHERE spl1 LIKE ('%$search%') LIMIT 1";
$result=mysql_query($sql) or die (mysql_error());
$rows=mysql_fetch_array($result);
$passon=$rows['orsku'];

//added code 
if (!is_numeric($rows['orsku']))
{
    echo 'The data must consist only of numeric characters.';
}

 

You'll most likely want to store the error as opposed to just echoing it out though, otherwise how will you to determine later if there actually was an error?

Link to comment
https://forums.phpfreaks.com/topic/202026-error-level/#findComment-1059403
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.