[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Value not showing up from table in db

Posted on 2007-03-21
18
Medium Priority
?
210 Views
Last Modified: 2007-03-21
I'm trying to figure out why I'm not getting the value from the database with the following code.  I know there is information for the field strProviderservice because I have already checked.  Can anyone help?

<?php
$conn = mysql_connect("127.0.0.1","root","t@rh33l");
mysql_select_db("providers",$conn);

$sql = mysql_query("SELECT strProviderservice From tblAdspace WHERE strProviderservice = '".$_POST['request']."'");

while ($row = mysql_fetch_array($sql)) {
      $strProviderservice = $row['strProviderservice'];
}
?>
<table width="275" cellpadding="5" cellspacing="0" border="0" class="cityborder" align="center">
<tr><td class="city_head" align="center" colspan="2">
Enter Your Zip Code or Town<br />
<span style="font-size: 9px; font-family: verdana; font-weight: normal">(In or near Moore County, NC)</span></td></tr>
<tr><form action="/providers.php" method="post">
<?php
if ($_REQUEST["request"] == "electrician") {
      $typeValue = "electrician";
} elseif ($_REQUEST["request"] == "painting") {
      $typeValue = "painting";
} elseif ($_REQUEST["request"] == "plumbing") {
      $typeValue = "plumbing";
}
?>
<input type="hidden" name="type" value="<?= $typeValue ?>">
<input type="hidden" name="strProviderservice" value="<?= $strProviderservice ?>">
<?= $strProviderservice?>  <----- Not getting anything ot display
0
Comment
Question by:pingeyeg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 3
18 Comments
 
LVL 24

Expert Comment

by:glcummins
ID: 18766621
You should add an 'echo' in front of the variable names to get them to display:

<input type="hidden" name="type" value="<?= echo $typeValue ?>">
<input type="hidden" name="strProviderservice" value="<?= echo $strProviderservice ?>">
<?= echo $strProviderservice?>  <----- Not getting anything ot display
0
 
LVL 3

Expert Comment

by:exoska
ID: 18766649
use the
      while ($row = mysql_fetch_array($sql))
like
      while ( $row = mysql_fetch_array($sql, 'MYSQL_ASSOC' ) )
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766651
When I place the echo command in front of the variable I get an error saying:

Parse error: parse error, expecting `','' or `';'' in /Library/WebServer/Documents/address.php on line 336

I typed <?= echo strProviderservice ?>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 24

Expert Comment

by:glcummins
ID: 18766670
Out of curiosity, why are you using '<?=' rather than '<?php'. I have never encountered that tag before.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766688
Isn't that what I am doing at the beginning exoska?

while ($row = mysql_fetch_array($sql)) {
      $strProviderservice = $row['strProviderservice'];
}
0
 
LVL 3

Expert Comment

by:exoska
ID: 18766691
if MYSQL_ASSOC does not work check if $_POST array includes the request .

try it with
   print_r($_POST);

replace all $_POST with $_REQUEST
and try that way..
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18766696
Okay, I just checked the PHP manual, and '<?=' is a shortcut for '<?php echo '. So, using echo after the '=' will cause problems. I apologize.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766698
I have used it before and it worked, even when I try the other way nothing happens.
0
 
LVL 3

Expert Comment

by:exoska
ID: 18766708
have you tried it with the MYSQL_ASSOC parameter like i d said ?
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766722
Not a problem.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766737
When I try that exoska, I get the following error:

Warning: mysql_fetch_array() [function.mysql-fetch-array]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in /Library/WebServer/Documents/address.php on line 316
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766781
Where do I place the print_r($_POST); ?
0
 
LVL 3

Accepted Solution

by:
exoska earned 2000 total points
ID: 18766835
bottom of the page would be good
but,
i ve realized something
SELECT strProviderservice From tblAdspace WHERE strProviderservice = '".$_POST['request']."'"

buddy, you are requesting the strProviderservice from tblAdspace giving the strProviderservice in the where clause as well. you already got that right? i mean the strProviderservice . it can be the  problem.. maybe something in the query is wrong, it seems so.
0
 
LVL 3

Assisted Solution

by:exoska
exoska earned 2000 total points
ID: 18766855
currently you are asking something like select color from colors where color='red'

you might have to request the ID or maybe you are searching for a phrase
i mean strProviderservice field may contain something like "aaabbccc" as a row and request may be "abbbc" so  you  should be querying like

SELECT strProviderservice From tblAdspace WHERE strProviderservice LIKE '%".$_POST['request']."'%"
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766873
I see what you are saying.  What I am trying to do is request the hidden value of strProviderservice from the form on the prior page.  That way I can keep carrying that value to the next page.
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 18766902
Man, I feel like an idiot.  The whole time I was thinking that I needed to request the info from the form on the prior page, but what I needed was from the query string.  I got it working now.  Thanks!
0
 
LVL 3

Expert Comment

by:exoska
ID: 18766937
buddy then just use

<input type="hidden" name="strProviderservice" value="<?= $request?>">
<?= $request?>  <----- Not getting anything ot display

if the previous pages form sends the "request" field in the post.
0
 
LVL 3

Expert Comment

by:exoska
ID: 18766981
so, any points to spend ? :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question