woocha Posted December 21, 2007 Share Posted December 21, 2007 Hey Guys....I can seem to find anything wrong with this code, can someone tell me what I am missing please? <? require('db_connect.php'); $query = "select * from merchant where merchant = $merchadmin"; $result = "mysql_query( $query)"; if ($result){ while ($r = mysql_fetch_array($result)) { $siteid = $r['site_id']; $email = $r['email']; } $wang = $r['site_id']; echo "$wang"; echo "<br />"; echo "$merchantdir"; echo "<br />"; echo "$merchadmin"; echo "<br />"; echo date("F, d, Y @ g:iA"); echo "<br />"; //echo "$r['id']"; echo "<br />"; echo "$id"; echo "<br />"; echo "$siteid"; echo "<br />"; echo "$merch"; echo "<br />"; echo "$email"; echo "<br />"; echo "$item_numb"; } else{ echo "its busted yo"; } ?> Thank You Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/ Share on other sites More sharing options...
peranha Posted December 21, 2007 Share Posted December 21, 2007 where are you setting $merchadmin at ? Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420103 Share on other sites More sharing options...
teng84 Posted December 21, 2007 Share Posted December 21, 2007 $result = "mysql_query( $query)"; should be $result= mysql_query( $query); Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420106 Share on other sites More sharing options...
woocha Posted December 21, 2007 Author Share Posted December 21, 2007 its a global...that's why I have the echo statement at the bottom echo "$merchadmin"; I also was thinking about that and echoed to the screen to make sure it was global Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420107 Share on other sites More sharing options...
woocha Posted December 21, 2007 Author Share Posted December 21, 2007 $result = "mysql_query( $query)"; should be $result= mysql_query( $query); I removing the quotes and now I am getting my home brew error message "its busted yo" Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420108 Share on other sites More sharing options...
teng84 Posted December 21, 2007 Share Posted December 21, 2007 post here the error? Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420114 Share on other sites More sharing options...
woocha Posted December 21, 2007 Author Share Posted December 21, 2007 No...I'm just not getting a $result, so the else statment executes and echos to this line runs else{ echo "its busted yo"; } Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420124 Share on other sites More sharing options...
woocha Posted December 21, 2007 Author Share Posted December 21, 2007 Is there a way to check to connection of my file DB_connect.php? Some sort of if no connection give a certain error or something? Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420135 Share on other sites More sharing options...
teng84 Posted December 21, 2007 Share Posted December 21, 2007 <? require('db_connect.php'); // also add a die on you connection $query = "select * from merchant where merchant = $merchadmin"; $result = mysql_query($query) or die(mysql_query()); if ($result){ while ($r = mysql_fetch_array($result)) { $siteid = $r['site_id']; $email = $r['email']; } $wang = $r['site_id']; echo "$wang"; echo "<br />"; echo "$merchantdir"; echo "<br />"; echo "$merchadmin"; echo "<br />"; echo date("F, d, Y @ g:iA"); echo "<br />"; //echo "$r['id']"; echo "<br />"; echo "$id"; echo "<br />"; echo "$siteid"; echo "<br />"; echo "$merch"; echo "<br />"; echo "$email"; echo "<br />"; echo "$item_numb"; } else{ echo "its busted yo"; } ?> Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420142 Share on other sites More sharing options...
woocha Posted December 21, 2007 Author Share Posted December 21, 2007 ok...Thank you...It must be the connection to my db, cause I ran the srcipt and got a blank white screen.. Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420151 Share on other sites More sharing options...
peranha Posted December 21, 2007 Share Posted December 21, 2007 What is in your db_connect.php page Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420152 Share on other sites More sharing options...
teng84 Posted December 21, 2007 Share Posted December 21, 2007 i believe you have your error reporting of because if you cant connect to db you should get some warning!!! Link to comment https://forums.phpfreaks.com/topic/82612-mysql-and-php-help-needed-with-a-querry/#findComment-420155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.