dottedquad
-
Posts
9 -
Joined
-
Last visited
Never
Posts posted by dottedquad
-
-
[code]<?PHP
echo '
<select name="state">';
if ( $_GET['ManageID'] == 'view' || $_GET['SectionID'] = 'forms' )
{
/*$df2 =& new dbfunctions();*/
$df->dbconnect('localhost', '****', '*****', 'gold');
$df->dbconnect('localhost', '****', '*****', 'website');
$state = mysql_query("SELECT `state` FROM `memberships` WHERE `id` = 20"); /* supposed to grab that persons state from the gold database */
$get_state = mysql_fetch_array($state);
echo $get_state['state']; /*this isn't echoing out either*/
$db_state = mysql_query("SELECT * FROM `states`"); /*supposed to grab the states from the website database*/
while ( $row = mysql_fetch_array($db_state) /*this seems to be working correctly!*/
{
if ( $_GET['ManageID'] == 'view' && $get_state['state'] == $row['state_id'] )
{
echo '<option value="' . $row['state_id'] . '" selected >' . $row['state_name'];
} else
{
echo '<option value="' . $row['state_id'] . '">' . $row['state_name'];
}
}
}
echo '</select> ';
?>[/code]
The issue I think, has to do with: [code]$state = mysql_query("SELECT `state` FROM `memberships` WHERE `id` = 20");[/code]. What I don't understand is I ran that query in phpmyadmin and it found a match. Also [code]echo $get_state['state'];[/code] is not echoing out the results there for, [code]if ( $_GET['ManageID'] == 'view' && $get_state['state'] == $row['state_id'] )[/code] conditional is false. -
[quote author=kenrbnsn link=topic=99918.msg393801#msg393801 date=1152408061]
You either have to return them back to the calling scope or declare them global inside your routine. I prefer to return them in an array:
[code]<?php
list ($fname, $lname, $dob) = chk_member();
function chk_member()
{
$location = "localhost";
$username = "root";
$password = "2dollarbill";
$database = "gold";
$conn = mysql_connect($location, $username, $password);
if (!$conn) { die ("Could not connect to MySQL"); }
mysql_select_db($database,$conn) or die ("Could not open database");
$sql = mysql_query("SELECT `memid`, `fname`, `lname` FROM `membership` WHERE `memid` = 1234567891");
$row = mysql_fetch_row($sql);
return (array($row[0], $row[1], $row[3]));
}
?>[/code]
Ken
[/quote]
sweet that works, is there any way I can break up the those variables to echo them out seperatly? -
[quote author=ShiVer link=topic=99918.msg393790#msg393790 date=1152406386]
I've always thought you chould just echo them. Can you not?
[/quote]
Ya I can echo out the variables inside of the function, but i'm trying to echo them outside of the function. It won't since i'm outside of the function scope. -
function code:
[code] function chk_member()
{
$location = "localhost";
$username = "root";
$password = "2dollarbill";
$database = "gold";
$conn = mysql_connect($location, $username, $password);
if (!$conn) { die ("Could not connect to MySQL"); }
mysql_select_db($database,$conn) or die ("Could not open database");
$sql = mysql_query("SELECT `memid`, `fname`, `lname` FROM `membership` WHERE `memid` = 1234567891");
$row = mysql_fetch_row($sql);
$fname = $row[0];
$lname = $row[1];
$dob = $row[3];
}[/code]
How do I access $fname, $lname, and $dob outside of the chk_member function so I echo out the values of those variables? -
[!--quoteo(post=388837:date=Jun 28 2006, 10:23 AM:name=Destramic)--][div class=\'quotetop\']QUOTE(Destramic @ Jun 28 2006, 10:23 AM) [snapback]388837[/snapback][/div][div class=\'quotemain\'][!--quotec--]
that should work
[code]
<input name="username" type="text" id="username" value="<?PHP echo $_POST['username']; ?>">
[/code]
[/quote]
Thanks! That worked :-) -
[code]<input name="username" type="text" id="username" <?PHP echo 'value="$_POST['username']"'; ?> >[/code] that is giving me: Parse error: parse error, unexpected T_STRING, expecting ',' or ';' on line 8 Could anyone help me with this issue?
-Thanks -
Setup: Windows XP Pro, PHP5, and MySQL5.0
My php directory is located in my c:\ which is my root. I didn't feel the need to add the libmysql.dll file and the php.ini to the system directory since I added C:\php to the [i]PATH[/i]
doc_root = "c:\inetpub\wwwroot"
extension_dir = "c:\php\ext"
extension=php_mysql.dll
I added ;C:\php to the [i]PATH[/i]
I restarted windows XP pro and I still get Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\fitness\dbtest.php on line 15
Am I missing a step here? I have no clue what to do from here.
-Thanks -
Sorry for the typo in the thread title. I meant to ask is there a Case Insensative SQL query?
-Thanks
Please, Help me.. ( Sessions ) !
in PHP Coding Help
Posted
[color=brown]
Oh :( I think what I have written above is wrong :-\
please can any one help ? :-[
I don't know why is the session not working !! [/color]
[/quote]
try reading the sessions in the FAQ: http://www.phpfreaks.com/forums/index.php/topic,31047.0.html