Heinz Stapff Posted August 6, 2011 Report Share Posted August 6, 2011 Getting Access denied with this code $link=mysql_connect("localhost","root","root")or die(mysql_error( )); mysql_select_db("bwi",$link) or die(mysql_error( )); $result=msql_query("SELECT Code,Item,Description,Href,Src FROM silver")or die(mysql_error( )); What password and ussername do I have to use with mysql_connect???????????????????????????????????I haven't changed them and Uniserver is running on thumb drive. Quote Link to comment Share on other sites More sharing options...
BobS Posted August 8, 2011 Report Share Posted August 8, 2011 $result=msql_query("SELECT Code,Item,Description,Href,Src FROM silver")or die(mysql_error( ));Is that call supposed to be mysql_query() instead? This might be your problem. You can use root/root if that's what you still have configured, but that also means you're wide open to attack, because it's NOT secure. You should set up a restricted user (through phpMyAdmin), and assign that user to the specific database. The user should have select, insert, update, and delete at a minimum. Regards,BobS Quote Link to comment Share on other sites More sharing options...
Heinz Stapff Posted August 8, 2011 Author Report Share Posted August 8, 2011 BobSYou could be right, I'll check it out, should be mysql_query() first, then $result but acctualy the whole script runs like this and draws the error in the div designated for the http response <?php $link=mysql_connect("localhost","root","root")or die(mysql_error( )); mysql_select_db("bwi",$link) or die(mysql_error( )); $query=mysql_query("SELECT Code,Item,Description,Href,Src FROM silver")or die(mysql_error( )); echo "<table border='1'> <tr> <th>Code</th> <th>Item</th> <th>Description</th> <th>Href</th> <th>Src</th> </tr>"; while($row = mysql_fetch_array($query))// could be msql_fetch_row($query) ??? { echo "<tr>\n"; echo "<td>" . $row['Code'] . "</td>\n";// don't know if new line is required? echo "<td>" . $row['Item'] . "</td>\n"; echo "<td>" . $row['Description'] . "</td>\n"; echo "<td>" . $row['Href'] . "</td>\n"; echo "<td>" . $row['Src'] . "</td>\n"; // don't know if it should be $row[5] ref? echo "</tr>"; } echo "</table>"; mysql_close($link); ?> Sorry BobS I think your right that this is not the place for tutorials but I need to know UniServer is working properly before I proceed. Quote Link to comment Share on other sites More sharing options...
Heinz Stapff Posted August 8, 2011 Author Report Share Posted August 8, 2011 Hay Coral, BobS was right and it worked, the div innerHTML gets the output from query the only thing is that the getSilver.php returns the #comment at the top of the php page along with the table. Is there a way to write the SELECT that dosen't return the #Comment in the php page? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.