Jump to content

not able to get an output pls help


udaystrad

Recommended Posts

Heres the code

dont kno wats the problem

 
<?php
 
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password="india123"; // Mysql password 
$db_name="test"; // Database name 
$tbl_name="members"; // Table name 
 
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
 
$myusername="maruti"; 
$mypassword="india123";
 

 
$dim="MID"; //  column name 
 
$mid="SELECT $dim FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
 
echo $mid;
 
 
 
?>
 
Link to comment
https://forums.phpfreaks.com/topic/283911-not-able-to-get-an-output-pls-help/
Share on other sites

Hey sir but the same codes worked out for me after some changes.....

or n may be i didnt understand what exactly u r tryin to say bcoz u r an expert and ur chances are more to be right....bt stil i have solved my issue...

 

Here is the code below 

 

 

 
<?php
 
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password="india123"; // Mysql password 
$db_name="test"; // Database name 
$tbl_name="members"; // Table name 
 
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
 
$myusername="maruti"; 
$mypassword="india123";
 
// If result matched $myusername and $mypassword, table row must be 1 row
 
$dim="MID";
$attendance="attendance";
 // Table name 
$takevalue=mysql_query("SELECT $dim FROM $tbl_name WHERE username='$myusername' and password='$mypassword'");
 
$array = mysql_fetch_array($takevalue); 
 
$mid=$array['MID'];
echo $mid.'<br/>';
 

 
//;
?>

Sir pls guide me what exactly u wer tryin to say...or i have got it by myself????

 

 

n i m  also stuck with one more databse problem heres the code

its nt workin????

 

thers no output(not getin inserted in database)

NO error showing. 

 

let me remind you i have tried sme other format also (which didnt work)...although dont have it .... pLs give me the line you think is right coz i have been stuck on this for a while....

 
mysql_query("INSERT INTO $attendance ('MemberId,TimeIn,TimeOut,Day,Month,Year')  VALUES ('$mid','$timein','$timeout','$day','$month','$year') ");
 

put in some checks

$sql = "SELECT $dim FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$takevalue=mysql_query($sql);

// check for errors in query
if (!$takevalue) {
    echo "$sql<br>" . mysql_error();
}
else {
    // check if any records found
    if (mysql_num_rows($takevalue)==0) {
        echo "No matching records<br>";
    }
    else {
        $array = mysql_fetch_array($takevalue); 
 
        $mid=$array['MID'];
        echo $mid.'<br/>';    
    }
}
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.