mysql - php access error using credentials that work in another script -
i'm ios developer trying update bit 'o php work mysqli_* stuff instead of deprecated mysql_* stuff.
i know next nothing php/mysql, , i'm stuck. i'm using script found @ http://www.w3schools.com/php/php_mysql_select.asp, changes reflect field names etc
when call following browser access error (connection failed: access denied user 'whoisit7'@'localhost' (using password: yes)). server name, password , username etc i'm using work existing script in browser not new one.
can point me @ i'm getting wrong?
<?php $servername = "localhost"; $username = "whoisit7_ios"; $password = "blahblahblah"; $dbname = "whoisit7_scathing"; // create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // check connection if (!$conn) { die("connection failed: " . mysqli_connect_error()); } $sql = "select name, latitude, longitude location status = 1"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "name: " . $row["name"]. " - latlong: " . $row["latitude"]. " " . $row["longitude"]. "<br>"; } } else { echo "0 results"; } mysqli_close($conn); ?>
in php, variable names case-sensitive. so, change connection variable names to:
$servername = "localhost"; $username = "whoisit7_ios"; $password = "blahblahblah"; $dbname = "whoisit7_scathing";
read if new php: http://php.net/manual/en/language.variables.basics.php
Comments
Post a Comment