Jump to content

[SOLVED] simple query problem...


wmguk

Recommended Posts

Hmm, im trying to do a simple query to a database and then show the results in a form..

 

<?php 
include "../scripts/connection.php";  
if (!$con)  
{  
  die( 'Could not connect: ' . mysql_error() );  
} 
mysql_select_db($db, $con); 

$sql = "SELECT * FROM album WHERE login = '$login'"; 

$result = mysql_query( $sql ) or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql<br><br>" ); 

$row = mysql_fetch_assoc($result);

  $active = $row['active'];
  $login = $row['login'];
  $pass = $row['password'];
  $ceremony = $row['ceremony'];
  $bride_firstname = $row['bride_firstname'];
  $bride_surname = $row['bride_surname'];
  $groom_firstname = $row['groom_firstname'];
  $groom_surname = $row['groom_surname'];
  $date_day = $row['date_day'];
  $date_month = $row['date_month'];
  $date_year = $row['date_year'];
  $venue = $row['venue'];
  $email = $row['email'];
  $image_no = $row['image_no'];
  $pricing = $row['pricing'];
  $postage = $row['postage'];
  
  $loginlower = strtolower($login);
  
?>

 

<?php echo $venue ; ?>

 

however this doesnt display the result. any ideas?

Link to comment
https://forums.phpfreaks.com/topic/66051-solved-simple-query-problem/
Share on other sites

then you're likely not returning any rows with that query.  try checking what mysql_num_rows() returns:

 

<?php 
include "../scripts/connection.php";  
if (!$con)  
{  
  die( 'Could not connect: ' . mysql_error() );  
} 
mysql_select_db($db, $con); 

$sql = "SELECT * FROM album WHERE login = '$login'"; 

$result = mysql_query( $sql ) or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql<br><br>" ); 

echo 'the query found '.mysql_num_rows($result).' rows.';

?>

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.