Jump to content

Simple - Retrieving values from SELECT


barney0o0

Recommended Posts

Hi Folks, as some of you may have agathered im a bit a newb...

 

Im trying to create values from a db that i can reference later in the script. Unfortunatley i use a combintaion of hand and dreamweaver, so please dont shoot me down..

There will only be one record available in the db. what im using after the connection is;

 

<?php

$date = @mysql_query('SELECT dateid FROM flyerdate');
  if (!$date) {
    exit('<p>Unable to get date</p>');
  }
  $feature = @mysql_query('SELECT featureid FROM flyerdate');
  if (!$feature) {
    exit('<p>Unable to get feature</p>');
  }
  $laban = @mysql_query('SELECT labanid FROM flyerdate');
  if (!$laban) {
    exit('<p>Unable to get laban</p>');
  }

?>

 

then later i try and cross reference thi svalue in the select statement

 

mysql_select_db($database_*, $*);
$query_Recordset1 = "SELECT * FROM events WHERE events.id = '".$feature."'";
$Recordset1 = mysql_query($query_Recordset1, $*) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

 

i dont get any errors, however i dont get any results....

 

ny ideas?..thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/106588-simple-retrieving-values-from-select/
Share on other sites

What gives with the $*'s

 


mysql_select_db($database_*, $*);

 

and

 

$Recordset1 = mysql_query($query_Recordset1, $*) or die(mysql_error());

 

are you just blanking things out here you don't want people to see?

 

are you sure that mysql_select_db is working, add a die().

 

Is $feature the correct variable, what if you var_dump the SQL command, does it look right?

 

 

 

Cheers

 

With the initial connection im using;

 

<?php

$dbcnx = @mysql_connect('*', '*', '*');

if (!$dbcnx) {

  exit('<p>Unable to connect to the ' .

      'database server at this time.</p>');

}
$db_selected = mysql_select_db("*", $dbcnx);

if (!$db_selected)
  {
  die ("Can\'t use test_db : " . mysql_error());
  }?>

 

the other $'s are just removed for safety

 

ive tried the var_dump using

 

<?php
$feature = @mysql_query('SELECT featureid FROM flyerdate');
  var_dump($feature);
?>

 

and i get 'resource(3) of type (mysql result)' (which i dont really undertsand!)

 

 

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.