Jump to content

[SOLVED] MYSQL Select Data WHERE


aramikgh

Recommended Posts

can someone please let me know what im doing wrong?

I thought this would be easy but i guess not...

 

basically there are variables being posted to this page and I need it to look up in the database and get the catalog_ID for ....

 

this is what i have so far...

<?
include 'config.php';
include 'opendb.php';


$DefCategory = $_POST['DefineCategory'];
$DefCatalog = $_POST['DefineCatalog'];
$DefPage = $_POST['DefinePage'];

echo "Processing Page " .$DefPage ." in " .$DefCatalog ." under the " .$DefCategory ." category.";


$result="SELECT Catagory_ID FROM a WHERE category_name = '{$_POST[DefineCategory]}' ";


while($row = mysql_fetch_array($result)) {
      $CategoryIDfromDB = $row["Catagory_ID"]; 

echo $row['Catagory_ID'];


}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/110525-solved-mysql-select-data-where/
Share on other sites

oops missed that...but for some reason i keep getting the same error...

this is how my code looks now...

<?
include 'config.php';
include 'opendb.php';


$DefCategory = $_POST['DefineCategory'];
$DefCatalog = $_POST['DefineCatalog'];
$DefPage = $_POST['DefinePage'];

echo "Processing Page " .$DefPage ." in " .$DefCatalog ." under the " .$DefCategory ." category.";


$result = mysql_query("SELECT Catagory_ID FROM a WHERE category_name = $DefCategory");

while($row = mysql_fetch_array($result)) {
      $CategoryIDfromDB = $row["Catagory_ID"]; 

echo $row['Catagory_ID'];


}

?>

 

and this is the error i keep getting...

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/elemenu9/public_html/rexdist/processEntry.php on line 15

 

I thought that error for was when your not connected to a database but my config.php and opendb.php take care of that...right?

 

 

ok another problem...

i got it to move on without an error but i dont get a blank variable back...or just dont get anything back period...

any advise?

<?
include 'config.php';
include 'opendb.php';


$DefCategory = $_POST['DefineCategory'];
$DefCatalog = $_POST['DefineCatalog'];
$DefPage = $_POST['DefinePage'];

echo "Processing Page " .$DefPage ." in " .$DefCatalog ." under the " .$DefCategory ." category.";


$result = mysql_query("SELECT Category_ID FROM a WHERE category_name = '$_POST[DefineCategory]' ") or die(mysql_error());

echo $result['Category_ID'];


while($row = mysql_fetch_array($result)) {
      $CategoryIDfromDB = $row["Catagory_ID"]; 

echo "<br /> your Category ID is: " .$CategoryIDfromDB;



}

?>

 

anything is appreciated.

 

 

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.