Jump to content

Setting in phpMyAdmin? This is driving me crazy!


blackenedheart

Recommended Posts

Hi Everyone,

 

This is my first post so please let me know if this is not the appropriate place for this.  Also, I would like to thank anyone who is willing to help me in advance.

 

My server is running the newest versions of phpMyAdmin and MySQL.

 

I am trying to perform a simple task of pulling data from my database and I am almost 100% sure the code is perfect.  So I think there is a problem with my phpMyAdmin settings.  But what could it be? 

 

What I have is 3 records in a table called "registration" and I am trying to format those into an HTML table.  

 

Here is my code.

 

 

<html>
<title>Search The Database</title>
<body bgcolor="#000000" text="#FF0000" link="#00FF00">
<p> </p>
<p> </p>
<p> </p>
<table width="81%" height="92" border="0" align="center" cellpadding="10" cellspacing="10" bordercolor="#FF0000" bgcolor="#FF0000">
  <tr bgcolor="#000000"> 
    <td width="15%" height="45"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">FIRST 
        NAME </font></strong></div></td>
    <td width="14%"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">LAST 
        NAME</font></strong></div></td>
    <td width="7%"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">CITY</font></strong></div></td>
    <td width="9%"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">STATE</font></strong></div></td>
    <td width="12%"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">COUNTRY</font></strong></div></td>
    <td width="9%"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">EMAIL</font></strong></div></td>
    <td width="14%"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">PASSWORD</font></strong></div></td>
    <td width="20%"><div align="center"><strong><font size="3" face="Courier New, Courier, mono">PASSWORD 
        TWICE </font></strong></div></td>
  </tr>
 
<?php
 
$host="XXX"; 
$username="XXX"; 
$password="XXX";  
$database="XXX";
$connection=mysql_connect("$host", "$username", "$password");
$selectdatabase=mysql_select_db($database);
$databasequery = "SELECT * FROM registration";   
$result = @sqli_query($connection, $databasequery);
 
if ($result) 
{
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
 
$firstname =  $row ['firstname'];
$lastname  =  $row ['lastname'];
$city  = $row ['city'];
$state  =  $row ['state'];
$country  = $row ['country'];
$email  =  $row ['email'];
$password  = $row ['password'];
$passwordverify = $row ['passwordverify'];
 
echo "<tr>";
echo '<td> .$firstname. </td>';
echo '<td> .$lastname. </td>';
echo '<td> .$city. </td>';
echo '<td> .$state. </td>';
echo '<td> .$country. </td>';
echo '<td> .$email. </td>';
echo '<td> .$password. </td>';
echo '<td> .$passwordverify. </td>';
echo "</tr>";
 
 
 
}
}
 
?>
 
</table>
</body>
</html>
Edited by ignace
Added code tags
Link to comment
Share on other sites

And forget you ever heard of the error suppression operator ("@").

 

 

$connection=mysql_connect("$host", "$username", "$password");
$selectdatabase=mysql_select_db($database);
$databasequery = "SELECT * FROM registration";   
$result = @sqli_query($connection, $databasequery);
 
if ($result) 
{
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))

 

 

Your connection and database selection are using the mysql extension.

Your fetch is using the mysqli extension

Your query is calling a function that does not exist, but you have suppressed the error -- looks like you tried to use mysqli. But as Barand said you can't mix them. Use one or the other, and since the mysql (no "i") extension is deprecated, you should use mysqli

Link to comment
Share on other sites

Ahh I get it now... I have a lot of books on MySQL but not MySQLi... 

 

Also, can I ask while I have some attention here, where can I learn more about PDO?  I have not been able to find a book that really describes PDO.  I am also trying to learn ColdFusion, but can't figure out why so many people are "abandoning" ColdFusion...

Link to comment
Share on other sites

I updated with this, but again no luck...

 

 

<?php
 
$host="XXX"; 
$username="XXX"; 
$password="XXX"; 
$database="XXX";
$mysqli = new mysqli("$host", "$username", "$password", "$database");
$query = "SELECT firstname, lastname, city, state, country FROM registration ORDER by ID DESC LIMIT 50,5";
 
if ($result = $mysqli->query($query)) 
 
{
 
while ($row = $result->fetch_assoc()) 
 
{
 printf ("%s (%s)\n", $row["First Name"], $row["Last Name"]);
}
$result->free();
}
 
$mysqli->close();
 
?>
Edited by ignace
Added code tags
Link to comment
Share on other sites

1. Don't put variables in strings. $host, not "$host".

2. check for errors. See my signature on debugging SQL.

3. print_r($row) will show you what's in the row. You will not have an array key of "First Name" when you selected "first_name" (And you should never have an array key or column name with spaces.)

Link to comment
Share on other sites

Hi Guys... Thanks for your help so far.  What I am trying to do unfortunately still is not working, but that's my issue for now.  I am coming over from being an iPhone/Objective-C programmer and MySQL is kicking my ass.

 

PHP is a lot like Objective-C but dealing with phpMyAdmin is driving me crazy.  I'm looking into DHTML as well as ColdFusion because at this rate, nothing will ever get done!

 

:)

 

Frankly, I am having my doubts about the phpMyAdmin MySQL combination.  Data retrieval on the web should not be this difficult or unreliable.

Link to comment
Share on other sites

I wanted to update this again by saying that some of the people that "hardcode" for MYSQL should consider trying a backend like MURA.  It's quite different than WORDPRESS and it's COLDFUSION powered.

 

Again, not trying to lead anyone astray here, but sometimes "hardcoding" is just plain to "hard."

 

Why stunt your creativity when it's all handed to you on a silver platter?

Link to comment
Share on other sites

I have a lot of books on MySQL but not MySQLi...

MySQLi extension (mysqli_* functions) is the successor of the MySQL extension (mysql_* functions), this is merely a PHP thing and has nothing to do with the actual database. You are however encouraged to use these new functions as the mysql_* functions are deprecated and will be removed in future versions of PHP. Edited by ignace
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.