So I am trying to check to see if this array has an underscore in it. I am not sure if I am using the correct function to do this. Any input would be appreciated.
Some more info, if the array does have an underscore I want it to run the code below. This code seperates and gives me the attributes that I want. I also check if it has and S and then run some code. These are all output to queries which are then queried at the end.
if (count($h)==3){
if (strpos($h[2], '_') !== false) // test to see if this is a weird quiestion ID with an underscore
{
if (strpos($h[2], 'S') !== false)
{
// it has an S
$underscoreLocation = strpos($h[2], '_');
$parent = substr($h[2], 0, $underscoreLocation - 6); // start at beginning and go to S
$title = substr($h[2], $underscoreLocation - 5, 5);
$questions = "select question from lime_questions where sid =".$h[0]." and gid =".$h[1]." and parent_qid =".$parent." and title =".$title.";";
}
else
{
// there is no S
$underscoreLocation = strpos($h[2], '_');
$parent = substr($h[2], 0, $underscoreLocation - 2);
$title = substr($h[2], $underscoreLocation - 1, 1);
$questions = "select question from lime_questions where sid =".$h[0]." and gid =".$h[1]." and parent_qid =".$parent." and title =".$title.";";
}
}
else
{
$questions = "select question from lime_questions where sid =".$h[0]." and gid =".$h[1]." and qid =".$h[2].";";
}
mysql_*functions in new code. They are no longer maintained and the deprecation process has begun on it. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.