Jump to content

Recommended Posts

Hey,

 

I have a table called store names that i am trying to do a mysql_fetch_array on. When i pass an ID in to the where clause, it does the mysql_fetch_array. However when I pass in the second coloumn the store_name it gives me an error saying that there is an unkown coloumn in the where clause?

 

Below is the code I am using.

 

$store_name = store1;
function get_store_information($store_name) {
$query = "SELECT * FROM store_names ";
$query .= "WHERE store_name = {$store_name} ";
$result = mysql_query($query);
confirm_query($result);
if($return_array = mysql_fetch_array($result)) {
return $return_array;
}else {
echo "There was an issue reading the store name table";
   }
}
$store_array = get_store_information($store_name);
echo $store_array['username'];

Link to comment
https://forums.phpfreaks.com/topic/274805-need-help-running-a-mysql_query/
Share on other sites

Jessica,

 

I apologize I forgot to enter the quotes on store name, when tryping the post. The store name is a $_GET value that gets passed in the function. But everytime it runs the query it says it can't find that specific store name in the "store_name" coloumn.

 

Strike that, read too fast.

 

Attempt 2: You're sending MySQL a string. Strings need to be quoted. It thinks your variable's value is a column name.

PHP automatically decodes the values in the $_GET (and $_POST) array. Unless you are encoding (via Javascript or something) in addition to what the browser does, there is no need to urldecode() the $_GET (or $_POST) array.

 

@eldan88

... it says it can't find that specific store name in the "store_name" coloumn

 

What says that? The code you provided could not possibly be saying anything like that. It is more helpful to copy & paste your actual code, than it is to provide a typed-out example that is something-like your code.

 

Show us the real code;

Use mysql_error to see the error message (copy and paste the entire message here);

echo the actual query and show us what it looks like;

 

Maybe we can help.

Jessica,

 

I apologize I forgot to enter the quotes on store name, when tryping the post. The store name is a $_GET value that gets passed in the function. But everytime it runs the query it says it can't find that specific store name in the "store_name" coloumn.

 

 

So....you read my post, said you had already done this, and then in the end that was the problem....

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.