Page 1 of 1

php and mysql

Posted: Sun Jul 22, 2012 2:34 pm
by Omgzr
Hey, am trying to make a query that shows me all the mails registered into my database.
My database name is registros
My table name is ingreso
The var for mail is called correo in my program

I tried that but is not working for me, if you guys can help me to find the mistake I would appreciate it

Code: Select all

<html>
<body bgcolor="black">

<b>

<head><title>Administrador</title></head>

<h1 align="center" class="Estilo1"><font face="bell mt cursiva" color="darkred" size="12">
<font face="bell mt cursiva" color="darkred" size="12"> <marquee bgcolor="black">Usuarios registrados en la base de datos</marquee></font>
<center><img src="iupsm.jpg" style="border:15px solid#333300" width="397" height="268"></center>


<?php
$conexion=mysql_pconnect("localhost","root","");
if(!$conexion){
echo "No Se Pudo Conectar";
exit;
}
mysql_select_db("registros");

echo '<h2>Usuarios registrados:</h2>';

$sql = "SELECT correo FROM ingreso";

// run the query. Will return a resource or false
$result = mysql_query($sql);

// if it ran OK
if ($result) {
// while I have more results, loop through them
// returning each result as an array
while ($user = mysql_fetch_array($result)) {
// use the array keys (column names) to output the data
echo $ingreso['correo'], '<br />';
}
}

Re: php and mysql

Posted: Sun Jul 22, 2012 4:20 pm
by gooney0
This line make no sense:

Code: Select all

echo $ingreso['correo'], '<br />';  
You don't have such a variable. Instead you should use $user.

Try print_r($user) and you'll see the resulting array from mysql_fetch_array.