Closed Thread Icon

Topic awaiting preservation: select code (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12928" title="Pages that link to Topic awaiting preservation: select code (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: select code <span class="small">(Page 1 of 1)</span>\

 
shalvi
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 10-11-2003 12:02

The following code should display fname and location to webpage...but it is not giving anyting..no error on the code and database is there successfully with the valu requestested....any help?

code
_______________________________________________________________________
<?php
$dbh=mysql_connect ("localhost", "root", "triadpass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("tuitionbd");

if (!$dbh) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}

if (! @mysql_select_db("tuitionbd") ) {
echo( "<P>Unable to locate the TUITIONBD " .
"database at this time.</P>" );
exit();
}

if($userlist = mysql_query(
"SELECT Fname,Lname,Tel,address,level,cityname FROM detail,city WHERE detail.AID=city.AID and cityname='$cityname'"))
{
while ($user = mysql_fetch_array($userlist)) {
$fname= $user["Fname"];
$lname = $user["Lname"];
$telephone= $user["Tel"];
$location = $user["address"];
$qualification= $user["level"];

echo( "<P>"$fname"<BR>" .
"(by $location</A> )</P>" );
}
}
else{
echo("<P>Error Showing details: " .
mysql_error() . "</P>");
}

?>
_______________________________________________________________________

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-11-2003 13:51

uh... this is a bit of a mess... let's see if I can straigthend it out to the point where I can see what's wrong with it,
so read my comments

code:
<?php
error_reporting(E_ALL); //we want this baby to tell us about it's errors.
$dbh=mysql_connect ("localhost", "root", "triadpass") or die ('I cannot connect to the database because: ' . mysql_error());
//either use mysql_connect or die (which is a bit of bad style, honestly,
//or check for your database handle later on.
//when the script has died because of 'or die', it will *never* execute that piece of code you got in
//if (!$dbh)

mysql_select_db ("tuitionbd");

if (!$dbh)
{ //sticking to the one true bracing style will make your code easier to read.
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
die(); //either die or exit - don't use two aliases for the same function!
}

if (! @mysql_select_db("tuitionbd") )
{
echo( "<P>Unable to locate the TUITIONBD " .
"database at this time.</P>" );
die();
}

if($userlist = mysql_query("SELECT Fname,Lname,
Tel,address,level,cityname
FROM detail,city
WHERE detail.AID=city.AID
AND cityname='$cityname'")) //AND is a MySQL keyword as well. Capitalize it ;-)
{
while ($user = mysql_fetch_array($userlist))
{
$fname= $user["Fname"];
$lname = $user["Lname"];
$telephone= $user["Tel"];
$location = $user["address"];
$qualification= $user["level"];
//BROKEN CODE; -)
// echo( "<P>"$fname"<BR>" .
// "(by $location</A> )</P>" );
//you got your " tangled up. some dots are actually missing
//either use
// echo( "<P>". $fname. "<BR>" .
// "(by $location</A> )</P>" );
// or (better in my opinion
// echo( "<P>{$fname}<BR>" .
// "(by {$location}</A> )</P>" );
//oh. and what's that buisness with the closing a whene there's no opening a?
}
}
else
{
echo("<P>Error Showing details: " .
mysql_error() . "</P>");
}

?>



hope this helps,

Tyberius Prime

shalvi
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 10-11-2003 20:56

thankx dude....it is working :-)

can u please figure out the problem i'm having for this stuff...some dudes suggested me ....but still I can't make it work... ...i wonder if you try a bit....
http://www.ozoneasylum.com/Forum12/HTML/001590.html

« BackwardsOnwards »

Show Forum Drop Down Menu