Jump to content

error level


hyster

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.