Jump to content

Help with my 1st PHP page


GodAtum

Recommended Posts

Hi all,

 

I'm new to PHP and have been following the various tutorials. I have come across a problem on the first page I have coded.

 

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\...

 

My code is:

 

    public function verify_user_credentials ($name, $password){
       return mysql_num_rows(mysql_query("SELECT * FROM t_users WHERE user = '"
                 . $name . "' AND password = '" . $password . "'"));
    }

 

 

User and password are CHAR fields.

Link to comment
https://forums.phpfreaks.com/topic/183858-help-with-my-1st-php-page/
Share on other sites

Common error, get used to it. :) It means that the call to mysql_query is failing and hence returning false, therefore mysql_num_rows cannot get a number of rows from the value FALSE. You will need to add some error trapping. echo out mysql_error to after running mysql_query to find out what the error may be.

Many thanks for all help. After echoing mysql_error() I discovered the problem, I misspelled the database name in my connection script  ::)

 

I am now tring to implement the Google Maps API. I am currently pulling a postcode from a databse into a table on a page. I need some help in passing that postcode into a text box on another page.

 

Address page:

        <table border="black">
            <tr>
                <th>Postcode</th>
                <th>Latitude</th>
                <th>Longitude</th>
            </tr>
            <?php
            $result = TiaDB::getInstance()->get_postcodes_by_person_id($personID);
            while($row = mysql_fetch_array($result)) {
                $postcode = $row["postcode"];
                $lat = $row["latitude"];
                $long = $row["longitude"];
                echo "<tr><td>" . strip_tags($postcode,'<br><p><h1>')."</td>";
                echo "<td>". strip_tags($lat)."</td>\n";
                echo "<td>". strip_tags($long)."</td></tr>\n";
            }
            ?>
        </table>

 

Maps page:

    <body>

Postcode: <input type="text" id="postcode" size="10" />
<input type="submit" value="Place Marker" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, placeMarkerAtPoint)" />
<input type="submit" value="Center Map" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, setCenterToPoint)" />
<input type="submit" value="Show Lat/Lng" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, showPointLatLng)" />

<div id="map">
</div>

    </body>

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.