hyster Posted May 17, 2010 Share Posted May 17, 2010 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 More sharing options...
trq Posted May 17, 2010 Share Posted May 17, 2010 You'd best take another look at preg_match. Link to comment https://forums.phpfreaks.com/topic/202026-error-level/#findComment-1059402 Share on other sites More sharing options...
Adam Posted May 17, 2010 Share Posted May 17, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.