pingeyeg
asked on
Value not showing up from table in db
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
<?php
$conn = mysql_connect("127.0.0.1",
mysql_select_db("providers
$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
use the
while ($row = mysql_fetch_array($sql))
like
while ( $row = mysql_fetch_array($sql, 'MYSQL_ASSOC' ) )
while ($row = mysql_fetch_array($sql))
like
while ( $row = mysql_fetch_array($sql, 'MYSQL_ASSOC' ) )
ASKER
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/Documen ts/address .php on line 336
I typed <?= echo strProviderservice ?>
Parse error: parse error, expecting `','' or `';'' in /Library/WebServer/Documen
I typed <?= echo strProviderservice ?>
Out of curiosity, why are you using '<?=' rather than '<?php'. I have never encountered that tag before.
ASKER
Isn't that what I am doing at the beginning exoska?
while ($row = mysql_fetch_array($sql)) {
$strProviderservice = $row['strProviderservice'] ;
}
while ($row = mysql_fetch_array($sql)) {
$strProviderservice = $row['strProviderservice']
}
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..
try it with
print_r($_POST);
replace all $_POST with $_REQUEST
and try that way..
Okay, I just checked the PHP manual, and '<?=' is a shortcut for '<?php echo '. So, using echo after the '=' will cause problems. I apologize.
ASKER
I have used it before and it worked, even when I try the other way nothing happens.
have you tried it with the MYSQL_ASSOC parameter like i d said ?
ASKER
Not a problem.
ASKER
When I try that exoska, I get the following error:
Warning: mysql_fetch_array() [function.mysql-fetch-arra y]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in /Library/WebServer/Documen ts/address .php on line 316
Warning: mysql_fetch_array() [function.mysql-fetch-arra
ASKER
Where do I place the print_r($_POST); ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
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!
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.
<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.
so, any points to spend ? :)
<input type="hidden" name="type" value="<?= echo $typeValue ?>">
<input type="hidden" name="strProviderservice" value="<?= echo $strProviderservice ?>">
<?= echo $strProviderservice?> <----- Not getting anything ot display