Okay, so I would like to say in advance, thank you for the help. With that said, I am having an extraordinary amount of trouble with some code. So here it is:

function school_user_exists($school_user = false, $school_id = false) {
    if($school_user || $school_id) {
        $school_user = sanitize($school_user);
        $school_id = (int)$school_id;
        $query = mysql_query("SELECT COUNT(`logs_id`) FROM `school_logs` WHERE `school_user` = '$school_user' AND `school_id` = '$school_id'");
        return (mysql_result($query, 0) == 1) ? true : false;
    } else {
        echo 'Something is amiss!';
    }
}
function logs_id_from_schooluser($school_user = false, $school_id = false) {
    if ($school_user || $school_id) {
        $school_user = sanitize($school_user);
        $school_id = (int)$school_id;
        return (mysql_result(mysql_query("SELECT `logs_id` FROM `school_logs` WHERE `school_user` = '$school_user' AND `school_id` = '$school_id'"),0, 'logs_id'));
    } else {
        echo 'There seems to be a parameter missing!';
    }
}

The logs_id_from_schooluser is giving the error:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 14 in /Users/Home/Sites/functions/users.php on line 6

As you can see I posted the functions in the manner that Im attempting to debug with. The tables do in fact have the information that is required as I put multiple mock accounts in to test them. Ideally, this should be returning the logs_id in order to update other fields in a separate account.

'$school_id'"),0, 'logs_id'));

Should this not be 1?

Afraid not. Doing such simply provides the following error:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 14 in /Users/Home/Sites/functions/users.php on line 6

From the error message one could conclude that the query returns 0 rows and therefore 1st row (index 0) can not be accessed. Please test the query with the actual parameters by inserting this code right after line 14:

die("SELECT `logs_id` FROM `school_logs` WHERE `school_user` = '$school_user' AND `school_id` = '$school_id'");

Copy the output into phpmyadmin or mysql client and see if the query returns any rows. Maybe the WHERE condition returns no rows.

Alright, it brought out the following.

SELECT logs_id FROM school_logs WHERE school_user = '********' AND school_id = '0'
(the ** are added by me, it is the correct user name selected)

Apparently the school_id isn't being picked up from the menu. Which, btw, is this portion:

if(empty($_POST) === false) {
    $school_user = $_POST['school_user'];
    $school_pass = $_POST['school_pass'];
    $school_id   = $_POST['school'];

    if (empty($school_user) === true || empty($school_pass) === true) {
        $errors[] = 'You must enter a username and password.';
    } else if (school_user_exists($school_user,$school_id) === false) {
        $errors[] = 'We were unable to locate that username. Please contact your school.';
    } else {
        $school_login = school_login($school_user, $school_pass);
        if ($school_login === false) {
            $errors[] = 'Either the username or password is incorrect.';
        } else {
            echo 'SUCCESS!';
            exit();
        }
    }   
} else {
    $errors[] = '';
}

<form id="schoolselect" action="" method="post">
    <ul>
        1. <?php echo '' . $lang['Country'] .  '';?>:<br>
        <li>         
            <select name="country"> 
                <?php 
                $country_query = "SELECT country_id, country_name FROM school_country"; 
                $country_result = mysql_query($country_query); 

                while($country = mysql_fetch_array($country_result))
                { 
                    if($_POST['country'] == $country['country_id'] ) 
                    { 
                        echo '<option selected value="' . $country['country_id'] . '">' . $country['country_name'] . '</option>'; 
                    } else { 
                        echo '<option value="' . $country['country_id'] . '">' . $country['country_name'] . '</option>'; 
                    } 
                } 
                ?>     
            </select> 
            <input type="submit" name="submit" value="<?php echo '' . $lang['Refine'] .  '';?>" /><br><br> 
        </li>
        2. <?php echo '' . $lang['Region or State'] .  '';?>:<br>
        <li>
                <select name="state"> 
                    <?php 
                    if($_POST['submit']) 
                    {   
                        echo $_POST['country']; 
                        $state_query = "SELECT state_id, state_name FROM school_state WHERE country_id = '{$_POST[country]}'"; 
                        $state_result = mysql_query($state_query); 

                        while($state = mysql_fetch_array($state_result)) 
                        {
                            if($_POST['state'] == $state['state_id'] ) 
                            { 
                                echo '<option selected value="' . $state['state_id'] . '">' . $state['state_name'] . '</option>'; 
                            } 
                                else 
                            {  
                                echo '<option value="' . $state['state_id'] . '">' . $state['state_name'] . '</option>'; 
                            }
                        }
                    } 
                    ?>
                </select> 
                <input type="submit" name="submit" value="<?php echo '' . $lang['Refine'] .  '';?>" /><br><br>
        </li>
        3. <?php echo '' . $lang['City'] .  '';?>:<br>
        <li>
                <select name="city"> 
                    <?php 
                    if($_POST['submit']) { 
                        echo $_POST['state']; 
                        $city_query = "SELECT city_id, city_name FROM school_city WHERE state_id = '{$_POST[state]}'"; 
                        $city_result = mysql_query($city_query); 

                        while($city = mysql_fetch_array($city_result))
                        {
                            if($_POST['city'] == $city['city_id'] ) 
                            { 
                                echo '<option selected value="' . $city['city_id'] . '">' . $city['city_name'] . '</option>'; 
                            } 
                                else
                            {
                                echo '<option value="' . $city['city_id'] . '">' . $city['city_name'] . '</option>';
                            }
                        } 
                    } 
                    ?> 
                </select> 
                <input type="submit" name="submit" value="<?php echo '' . $lang['Refine'] .  '';?>" /><br><br>
        </li>
        4. <?php echo '' . $lang['School'] .  '';?>:<br>
        <li>
                <select name="school"> 
                    <?php 
                    if($_POST['submit']) 
                    { 
                        echo $_POST['city']; 
                        $school_query = "SELECT school_id, school_name FROM school_list WHERE city_id = '{$_POST[city]}'"; 
                        $school_result = mysql_query($school_query); 

                        while($school = mysql_fetch_array($school_result)) 
                        {
                            if($_POST['school'] == $school['school_id'] ) 
                            { 
                                echo '<option selected value="' . $school['school_id'] . '">' . $school['school_name'] . '</option>'; 
                            } 
                                else
                            {
                                echo '<option value="' . $school['school_id'] . '">' . $school['school_name'] . '</option>';
                            }
                        }
                    }
                    ?> 
                </select> 
                <input type="submit" name="submit" value="<?php echo '' . $lang['Submit'] .  '';?>" /><br><br>
        </li>
        5. <?php echo '' . $lang['School Issued Username'] .  '';?>:<br>
        <li>
            <input type="text" name="school_user" required<?php if (isset($_POST['school_user']) === true) { echo 'value="', strip_tags($_POST['school_user']), '"'; } ?>><br><br>
        </li>
        6. <?php echo '' . $lang['School Issued Password'] .  '';?>:<br>
        <li>
            <input type="password" name="school_pass" required>
        </li>
    </ul>
    7. <input type="submit" name="submit" value="<?php echo '' . $lang['Add School'] .  '';?>" />
</form>

Which I think something isn't being passed through the value for schools.

Things are now working, thank you all very much!

Member Avatar for LastMitch

@rosse88

Can you click Solve because broj1 and Squidge answer your question. So in the future if someone have the similiar question, they can referred back to your question to find the answer.

Well technically speaking the help here was a nudge in the right direction and not an actual solution (still very helpful hence the now 'solved' mark). Thank you again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.