thebluestar 0 Junior Poster in Training

If I want to select the max value of 1 record, but there are two columns that having the same max values?
How can I select both of them?

thebluestar 0 Junior Poster in Training

I wonder if I can send an email via smtp using Gmail account without installing a mail server or not?
For example:
re_pass.asp

<p>Password Reminder</p>
<form method="post" action="re_pass_process.asp">
	<input type="text" name="email">
	<input type="submit" value="Send">
</form>

re_pass_process.asp

<!--#include file="connection.asp"-->
<%
openConn()
email = request("email")
response.Write(email)
''response.End()
if trim(email) <> "" then

	sql= "select password from candidate where email = '" & replace(email,"'","''") & "'"
	''response.Write(sql)
	''response.End()
	set rs = createobject("adodb.recordset")
	rs.open sql,conn
	''response.End()
	if not rs.eof then
		set msg = createobject("CDO.Message")		
		msg.to = email
		''response.Write(email)
		msg.from = "tranlinh.nmt@gmail.com"		
		msg.subject = "123456" ' pass for mail:tranlinh.nmt@gmail.com
		
		msg.TextBody = "Hello. Your password is " & rs("password")
		response.Write rs("password")
		''response.End()
		msg.Send
		response.End()
	end if
	rs.close
end if
%>

As above, what need to be installed to send an email?

thebluestar 0 Junior Poster in Training

I want to store a map that is drawn using Map info software, then store it into the database, but I have not known about spatial data in sql server
I tried creating a table using geometry data type like:

use master
go
CREATE TABLE Districts 
    (	DistrictId int IDENTITY (1,1),
DistrictName nvarchar(20),
    	DistrictGeo geometry);
GO

but it raised an error:Column, parameter, or variable #3: Cannot find data type geometry.
As far as I know the MS sql server 2005 is also support this data type

thebluestar 0 Junior Poster in Training

I have tried to upload the xml file into a column with xml type of the database table
I use sql statement like:

USE xml_tbl
go
INSERT INTO xml_tbl(Filename,DATA)
SELECT 'file1' a,*
FROM OPENROWSET( BULK 'C:\XML\file1.xml' ,SINGLE_CLOB)
as a

or into the existing column:

update tbl_xml
set data = (select * from openrowset (BULK 'C:\XML\file1.xml' ,SINGLE_CLOB) as x)
where Filename ='test'

but both of them raised an error "Msg 9438, Level 16, State 1, Line 1
XML parsing: line 2, character 6, text/xmldecl not at the beginning of input"
.
I don't know why?

thebluestar 0 Junior Poster in Training

I have tried to include a JavaScript asp file into a vbscript asp file, but I did work?
I know because they are "incompatible", but I don't know how to solve it!

thebluestar 0 Junior Poster in Training

Here I try to make a dynamic site, means the content only is displayed in a main part of website.Hmm, all related pages are called by the values that are passed by the URL.
Here is my source
Firstly, from the main.asp page I add page dynamic_site.asp to show other related pages: employerSite.asp, employerProfile.asp...
Now from the employerSite.asp (it contains many links to other pages), I want to display other links ( its sub-links) in it. It mains in that same page. The content of sub-links will be display belove the menu link (Register******Manage).
I get stuck here. When I check the action got from the url for sub-link (eg: employerRegister.asp) in the employerSite.asp it is empty!!!
http://www.mediafire.com/file/yzykjoggz2m/FRAME.rar
I cannot attach my files, so I insert a link!
Help me!

thebluestar 0 Junior Poster in Training

I using the value pass from url to open a new page but there are some mistakes,
but I cannot find them
here is my all files to do that:
main.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<%
	check = "ok"
%>
<body>


	<table width="100%" >
    
		<tr>
        	<td colspan="3" bgcolor="#990033">
            		<!--#include file="header.asp"-->
            </td>
        </tr>    
    	<tr>
        	<td width="20%" with="20%"><!--#include file="left.asp"--></td>
        	<td width="55%" bgcolor="#CCCCCC" with="60%">
            				<!--#include file="dynamic_site.asp"-->
            </td>
        	<td width="25%" >
            		<!--#include file="right.asp"-->
            </td>                        
        </tr>
        
		<tr>
        	<td colspan="3" bgcolor="#0000FF">
            		<!--#include file="footter.asp"-->            
            </td>
        </tr>
    </table>

</body>
</html>

dynamic_site.asp

<%
	module =	Request.QueryString("mod")
	action  =	Request.QueryString("do")
	
		select case module								
			case "employer"
				if(action="site") then
					%>
								<!--#include file="employerSite.asp"-->                
					<%
				end if
				
				if (action="profile") then
					%>
                				<!--#include file="employerProfile.asp"-->    
                	<%
				end if
				
			case "user"	
				if(action="search") then
					%>
								<!--#include file="search.asp"-->                
					<%
				end if
			case else  '
			%>
			<!--#include file="main.asp"-->     
			
		<%
		end select 	
%>

header.asp

Header

footer.asp

Footer

right.asp

Right

left.asp

<a href="?mod=employer&do=site" >Employer site</a><br/>
<a href="?mod=employer&do=profile" >Employer profile</a><br>
<a href="?mod=user&do=search">Search</a><br/>

employerSite.asp

<h3>Area for employer only!</h3><hr />
*********<a href="?mod=employer&do=register">Register</a>
*********<a href="?mod=employer&do=manage">Manage profile</a>

employerProfile.asp

Profile

search.asp

search

I think the problem in the dynamic_site.asp, but I dont' find any thing wrong with it!

thebluestar 0 Junior Poster in Training

I have tried to use session to track/ say 'Hello' to the user who is online.
However, I'm very new to use this object and actually, I'm still not clear all about the global.asa file. I mean we write all methods about sessions we'll in it , then call it in the asp file.
Sometimes, to start session, we have to start application first. I'm not clear about this, you can explain it for me? thank you!:)
and here is my source code:
(I have just made an example to try, it's not enough)
loginForm.asp

<html> 
<body> 

<form method="post" action="login.asp"> 
  <p>Username:
  <input type="text" name="user"> 
  </p>
  <p> Password:
    <input type="password" name="pass"> 
  </p>
  <p>
    <input type="submit" name="submit" value="Sign in"> 
    <br>
  </p>
</form> 
</body> 
</html>

login.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Xin chao, 
<%
session_OnStart()
'response.Write (session("started"))
session("user") = request.QueryString("user")
response.Write (session("user"))
%> 
</body>
</html>

Please help me figure out it, thank you!

thebluestar 0 Junior Poster in Training

I'm trying to study ASP and sql server 2005 to create the website.However, I don't know how to create a table having a column to store the image, I have never tried this before, I don't know sql server 2005 has data type of image or not.
hmm, the flow is: I will get the image from the user's uploading, insert it into the database, then I can select it and display into the website!
You can show me the tip or the way? please!

thebluestar 0 Junior Poster in Training

I have just tried to do like your suggestion but it also does not work properly.
Here is the error message: Invalid address: SMTP Error: Could not authenticate. sending email DONE!sending error: SMTP Error: Could not authenticate.
Should I need to change the smtp in the php.ini file because I see in this file the smtp port is 25 but in the PHPMailer it is 456.

thebluestar 0 Junior Poster in Training

I try this but it raised an error: Invalid address: @gmail.comSMTP Error: Could not authenticate. Failed to send message: SMTP Error: Could not authenticate.

thebluestar 0 Junior Poster in Training

I want to send an email from localhost but I don't know how to install mail server, so I do this way:

<?php
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Gui mail su dung PHPmailer and gmail</title>
</head>

<body>
<?php 
require_once('PHPMailer/class.phpmailer.php'); 
?>
<?php
define('GUSER', 'tranlinh.nmt@gmail.com'); // I wonder here: is this my gmail account?
define('GPWD', '123456'); // is this password for this email that will be sent
function smtpmailer($to, $from, $from_name, $subject, $body) { 
    global $error;
    $mail = new PHPMailer();  // tạo một đối tượng mới từ class PHPMailer
    $mail->IsSMTP(); // bật chức năng SMTP
    $mail->SMTPDebug = 0;  // kiểm tra lỗi : 1 là  hiển thị lỗi và thông báo cho ta biết, 2 = chỉ thông báo lỗi
    $mail->SMTPAuth = true;  // bật chức năng đăng nhập vào SMTP này
    $mail->SMTPSecure = 'ssl'; // sử dụng giao thức SSL vì gmail bắt buộc dùng cái này
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465; 
    $mail->Username = GUSER;  
    $mail->Password = GPWD;           
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AddAddress($to);
    if(!$mail->Send()) {
        $error = 'sending error: '.$mail->ErrorInfo; 
        return false;
    } else {
        $error = 'Done';
        return true;
    }
}  
smtpmailer('tranlinh.fit@gmail.com', '', 'tranlinh.nmt@mail.com', 'tranlinh', 'subject', 'content'); 
if (smtpmailer) {
    echo "sending email DONE!";
}
if (!empty($error)) echo $error;  
?>
</body>
</html>

But it raises error.I don't know why
Please help me clarify this problem! Thanks a lot!

thebluestar 0 Junior Poster in Training

I have already fixed this problem

public double getTotalCost() {
        double totalCost =0;
        int i;
        int len = items.length;
        System.out.println("length is" + len);
        for (i = 0; i < index; i++) {
            totalCost = totalCost + items[i].getCost();
        }
        return totalCost;
    }
thebluestar 0 Junior Poster in Training
package problem2class;

public class ShoppingListItem {

    private String name;
    private int numOfItems;
    private double price;

    public ShoppingListItem(String name, int quantity, double pricePerUnit) {
        this.name = name;
        numOfItems = quantity;
        price = pricePerUnit;

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumOfItems() {
        return numOfItems;
    }

    public void setNumOfItems(int numOfItems) {
        this.numOfItems = numOfItems;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getCost() {
        return numOfItems * price;
    }

    public void setQuantity(int quantity) {
        numOfItems = quantity;
    }
 
}
package problem2class;

public class ShoppingList {

    public static ShoppingListItem[] items = new ShoppingListItem[10];
    public static int index = 0;
 //   public static double totalCost;
    static ShoppingListItem I1 = new ShoppingListItem("milk", 2, 20);
    static ShoppingListItem I2 = new ShoppingListItem("cofee", 12, 2);

    public ShoppingList() {
    }

    public void add(ShoppingListItem i) {
        System.out.println("index is " + index);
        items[index] = new ShoppingListItem(i.getName(), i.getNumOfItems(), i.getPrice());
        System.out.println("adding done!" + items[index].getName() + "price" + items[index].getCost());
        index++;
    }

    public double getTotalCost() {
        double totalCost =0;
        int i;
        int len = items.length;
        System.out.println("length is" + len);
        for (i = 0; i < items.length; i++) {
            totalCost = totalCost + items[i].getCost();
            System.out.println("each" + items[i].getCost());
            System.out.println("totalCost" +totalCost);
        }
        return totalCost;
    }

    public static void main(String[] args) {
        ShoppingList L1 = new ShoppingList();
        L1.add(I1);
        L1.add(I2);
        System.out.println("Total cost is" + L1.getTotalCost());
    }
}

I mean the getTotalCost() in the shoppingList does not work, I don't know why.
Firstly, I have …

thebluestar 0 Junior Poster in Training

ShoppingListItem.java

package problem2class;

public class ShoppingListItem {

    private String name;
    private int numOfItems;
    private double price;

    public ShoppingListItem(String name, int quantity, double pricePerUnit) {
        this.name = name;
        numOfItems = quantity;
        price = pricePerUnit;

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumOfItems() {
        return numOfItems;
    }

    public void setNumOfItems(int numOfItems) {
        this.numOfItems = numOfItems;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getCost() {
        return numOfItems * price;
    }

    public void setQuantity(int quantity) {
        numOfItems = quantity;
    }
    public static void main(String[] linh) {
        ShoppingListItem I1;
        I1 = new ShoppingListItem("Kenturky",12,1200);
        System.out.println("Now show the content of the Item:");
        System.out.println("Name is:"+I1.getName() + " Price for each item:"+I1.getPrice() +" Num of items:"+I1.getNumOfItems());
        System.out.println("So the cost is: "+I1.getCost());
    }
}

ShoppingList.java

package problem2class;
public class ShoppingList {
    public static ShoppingListItem[] items = new ShoppingListItem[10];
  //  public static int index=0;
    public static double totalCost=0;
    static ShoppingListItem I1 = new ShoppingListItem("milk",1,23);
  //  static ShoppingListItem I2 = new ShoppingListItem("cofee",12,30);
    public ShoppingList() {

    }
    public void add(ShoppingListItem i) {
        items[0] = new ShoppingListItem(i.getName(),i.getNumOfItems(),i.getCost());
        //index++;
        System.out.println("adding done!");
    }
    public double getTotalCost() {
        //double totalCost =0;
        int i;
        int len = items.length;
        System.out.println("length is"+len);
        for (i = 0; i < items.length; i++) {
            totalCost =totalCost + items[i].getCost();
            System.out.println("each"+items[i].getCost());
        }
        return totalCost;
    }
    public static void main(String[] args) {
       ShoppingList L1 = new ShoppingList();
        L1.add(I1);
        System.out.println("Total cost is" + L1.getTotalCost());
    }
}

In the above exercise I …

thebluestar 0 Junior Poster in Training

Account.java

package btclass;

import java.util.Scanner;


public class Account {

    private float amount;//actual amount
    private static float balance;//balance amout
    Scanner keyboard = new Scanner(System.in);
    public void deposit() {
        System.out.println("Enter the amount you want to deposit: ");
        float depos = keyboard.nextFloat();
        if (depos < 0) {
            System.out.println("Amount you entered is < 0! It's possible!");
        } else {
            amount = amount + depos;
            System.out.println("So the actual amount now you have is: "+ amount);
            balance = amount;
        }
    }
    public void withdraw() {
        System.out.println("Enter the amount you want to withdraw: ");
        float getOut = keyboard.nextFloat();
        if (getOut > amount) {
            System.out.println("Cannot! the amount you want to withdraw is greater than actual amount!");
        } else {
            balance = amount - getOut;
            System.out.println("The amount left is: " + balance);
        }
    }
    public float getBalance() {
        return balance;
    }
}

AccountTest.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package btclass;

import java.util.Scanner;

/**
 *
 * @author Oner
 */
public class AccountTest {

    String accountNo;
    String setAccountNo = "123456";
    public static boolean goOn;
    public static boolean pinT = false;

    public static void main(String[] args) {
        Account myAccount = new Account();
        AccountTest AT1 = new AccountTest();
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Welcome to use ATM machine :D");
        System.out.println("Enter your PIN: ");
        while (pinT == false) {
            String pin = keyboard.nextLine();
            AT1.accountNo = pin;
            if (!AT1.accountNo.equalsIgnoreCase(AT1.setAccountNo)) {
                System.out.println("Incorrect PIN! Please Enter the correct PIN!");
                pinT = false; 
                continue;
            } else {
                pinT = true;
                goOn = …
thebluestar 0 Junior Poster in Training
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/javascript" src="js.js"></script>

</head>

<body>
<h2>Calculate the area</h2>

Choose shape
<form>
	<input type="radio" name="hinh" value="hcn" onclick="area(this.value)" />Rectangle
	<input type="radio" name="hinh" value="htron" onclick="area(this.value)"/>Circle
</form>
<div id="property"></div>

</body>
</html>
// JavaScript Document
function area(value)
{
	var prop = document.getElementById('property');
	var content="";
	if(value=='hcn')
	{
		
		content +="chieu dai:" + "<input type='text' name='width' />";
		content +="chieu rong:" + "<input type='text' name='height' />" +"<br/>";
		var inputWidth = document.forms[1].width.value;
		document.write(inputWidth);
		var w = parseFloat(inputWidth);
		var inputHeight = document.forms[0].height.value;
		var h = parseFloat(inputHeight); 
		content +="<input type='button' name='dtich1' value='Tinh dien tich' onclick=\"alert(w*h)\"/>";
		
	}
	prop.innerHTML = content;
	
}

Here is my code using innerHTML to calculate the area of 2 shapes, but it does not work properly.
I cannot get the value from the users' input

thebluestar 0 Junior Poster in Training
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
	function sendto()
	{
		var Lname = document.myform.last.value;
		var Fname = document.myform.first.value;
		document.write("Hello!," + " " + Fname + Lname);
		var choice = confirm("Your name is true? OR press Cancel to re-enter");
		if(choice==true)
		{
			alert("OK");
		}
		else
		{
			window.location="thisFile.htm";
			//here I don't know how to Focus on the Lastname textfied
			//because after I press Send button , the whole page is reloaded
			document.myform.last.focus();
		}
	}
</script>
</head>

<body>
<form action="" method="get" name="myform">
	Last name:<input name="last" type="text" size="10" /><br/><br/>
	Firstname:<input name="first" type="text" size="10" /><br/>
	<input name="" type="button" value="Send" onClick="sendto()"/>
</form>
</body>
</html>

This requires after the user enter their name, press Sendto button, all information will be sended to or displayed in the new page.
Then,they confirm the name they entered is true if not it will come back the first page and the lastname field is focused!
Please help me!

thebluestar 0 Junior Poster in Training

While saving the html code, I accidentally saved my code as encrypted code.
I don't remember what did I do.
More importantly, Now I dont' now decrypt it.
Please help me make it return as html code.
Thank a lot!

3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 50 
55 42 4C 49 43 20 22 2D 2F 2F 57 33 43 2F 2F 44 
54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 61 
6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 22 20 22 
68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 72 
67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 2F 
78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 6F 
6E 61 6C 2E 64 74 64 22 3E 0D 0A 3C 68 74 6D 6C 
20 78 6D 6C 6E 73 3D 22 68 74 74 70 3A 2F 2F 77 
77 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 
68 74 6D 6C 22 3E 0D 0A 3C 68 65 61 64 3E 0D 0A 
3C 6D 65 74 61 20 68 74 74 70 2D 65 71 75 69 76 
3D 22 43 6F 6E 74 65 6E 74 2D 54 79 70 …
thebluestar 0 Junior Poster in Training

I don't know how to use the onmouseover event the text , then display the image.
For example, I have a <p onmousever="">CHECK</p>, then when I move the mouse over the text, the image will display.
Please help me!

thebluestar 0 Junior Poster in Training
<html>
<head>
		<script type="text/javascript">
				function check()
				{
					var val = document.myForm.content.value;
					if (val.length <= 10)
					    {
					       document.getElementById('numC').value = val.length;
					       //out.value = val.length;
					       
					    }
					 else
						document.write("Please enter the text in  range of 10 characters!");
					return false;	
				} 
		</script>
</head>
<body> 
       <form name="myForm">
       Type something here:
       <input type"textbox" value="" name="content"  onchange ="check()">
       <br/><br/>
       Lenght of string you enter:<input type="text" id="numC">
       </form>
</body>
</html>

Here is my code with the requirement: when I type text into the first input cell, the number of characters will be appear in the next cell, or if the number of character is greater than 10, the inform will be appear.
But I don't know how the inform will appear immediately if the tenth character is typed!
Please help me!
Thank you!

thebluestar 0 Junior Poster in Training

you set the value to null then read it? Why are you using "while(list.options.length)"?

try this:

function getvalue(list)
{
document.getElementsByTagName("body")[0].bgColor=list.value;
}

Ok, ^^.Thank you very much!

thebluestar 0 Junior Poster in Training
<html>
<head>
 	<title>Nhung rac roi ko hieu</title>
	<script type="text/javascript">
			function getvalue(list)
			{
			     while(list.options.length) list.options[list.selectedIndex].value=null;
			     var value = list.options[list.selectedIndex].value;
			     document.write(value);
			     document.bgColor = value;
			}
	</script>
</head>
<body bgColor="lavender">
		Here is the list for you to Change the bgColor!
		<br/>
		<select name="list1" onchange="getvalue(this)">
				<option value="green">Green</option>
				<option value="orange">Orange</option>
				<option value="yellow">Yellow</option>
				<option value="pink">Pink</option>
		</select>
</body>
</html>

Here is my code , it works but how can I do to remain the list each time click one option . I mean when I click one option the background changes, also the combo box is remainded to try the next option!
Please help me clarify the problem. Thanks!

thebluestar 0 Junior Poster in Training
<html>
	<head>
		<title>Web just for training</title>
		<script type="text/javascrip">
				function chBG(kolor)
				{
				     document.getElementById('ab').style.background = kolor;
				}
		</script>
	</head>
	<body id="ab">
			<input type="button" name="b3" value="green" onclick="chBG(this.value)"><br/><br/>
			<input type="button" name="b4" value="blue" onclick="chBG(this.value)">
	</body>
</html>

Here is my code to change the background color but I does not work!I don't know why, please help me clarify the problem! Thank you!

thebluestar 0 Junior Poster in Training

Actually, I still do not understand the way the values which are inputted in the function Input to pass into sort function to Sort? Can you explain more for me? Thanks!

thebluestar 0 Junior Poster in Training
<html>
<head>      
</head>
<body>
         
	<script type="text/javascript">
	     
		    var arr = new Array();	
            var sortedARR = new Array();	
            // FORM to input the number of names		
			document.write("<form name=\"TEN\" method=\"\" action=\"\">");
			document.write(" Please enter the numbers of names u want to input:<input type=\"text\" name=\"NoName\"> ");
			var No = document.TEN.NoName.value;
			var N;
			N = eval(No); 
			document.write("<input type=\"button\" name=\"\" onclick=\"INPUT()\" value=\"Click for input!\" >");
			document.write("</form>");
			// FORM to input No of names
			function INPUT()
			{
			    document.write("<form name=\"TENDUOCNHAP\" method=\"\" action=\"\" >");
				var i;
			    for(i=0; i<N; i++)
					{
					     document.write("Name"+" "+i+":");
						 document.write("<input type=\"text\" name=\"input_name\" size=\"30px\" value=\" \" > <br/><br/>");
					}
				document.write("<input type=\"button\" name=\" \" onclick=\"SORT()\" value=\"Sortting!\" >");
				
			    document.write("</form>");
			}
            function SORT()
            {	
			    var i;
                for(i=0; i<N; i++)
					{
						arr[i] = document.TENDUOCNHAP.input_name.value;
						document.write(arr[i]);
					}			
				sortedARR=arr.sort();
				var x;
				for (x in sortedARR) 
				document.write(sortedARR[x]);
			}
				
					
	  </script>	   				
</body>
</html>

I don't know why that does not work? I can not sorting the array!
Please help me! Thanks!

thebluestar 0 Junior Poster in Training

I have installed the Ubuntu into my laptop .My origin operating system is Window7. Now I have installed the Ubuntu into another disk(E , Window7 in C), but when I start the computer , it always boots with Window7 without the choices asking which OS to start
I don't know why! Please help me!
Thanks a lot!

thebluestar 0 Junior Poster in Training

Oh, now I have one solution for that:

#include<stdio.h>
#include<conio.h>
#define MAX 20

int Input_N(int n)
{
    do
    {
     printf("Plz enter N in the range [0,20]");
     printf("Enter N numbers u want to input: ");
     scanf("%d",&n); 
    }while ( (n<0) || (n>20) );
     return n;
}

int (*input_n)(int) = Input_N;

void Get_N(int p[], int n)
{
    int i;
    printf("Ennter %d numbers: ",n); 
    for( i=0; i<n; i++)
    {
         printf("\nNumber%: ",i);
         scanf("%d",&p[i]);
    }
    for( i=0; i<n; i++)
    {
        printf(" %d",p[i]);  
    }
}

int main()
{
  int a[MAX],N;
  Get_N(a,input_n(N));
  getch();
  return 0;
}
thebluestar 0 Junior Poster in Training

Here is the problem:write in saparate function without using global variable
1/(function input)enter N in the range [0,20], then enter N numbers
2/(function display)Display N numbers in 2 columns
Here is my source code

#include<stdio.h>
#include<conio.h>
void Input(int *p,int n)
{
    int i;
    do
    {
     printf("Enter N numbers u want to input: ");
     scanf("%d",&n); 
    }while ( (n<0) || (n>20) );
    p =(int *)malloc(n*sizeof(int));
    printf("Ennter %d numbers: ",n);
    for( i=0; i<n; i++)
    {
         printf("\nNumber%: ",i);
         scanf("%d",p+i);
    }
    
}

void Display(int *p, int n)
{
     int i;
     printf("test");
     for( i=0; i<n; i++)
     {
        printf(" %d",p[i]);  
     }
}

int main()
{
  int *a, *N;
  Input(a,&N);
  Display(a,&N);
  getch();
  return 0;
}

I don't know how can I use the variable N in function input for the next function.

thebluestar 0 Junior Poster in Training
int Prime(int x)
{      
       int i;
        if (x==2) 
           return 0;
           else if (x < 2) 
                    return 1;
                 else
                 {
                    for( i=2; i<= (int)sqrt(x); i++ )
                    {
                       if( x % i == 0 )
                       return 1;
                    }
                    return 0; 
                 }  
}
void checkPrime()
{
     int i,j,k;
     printf("\nMatrix after check Prime\n");
     for(i=0; i<3; i++)
     { 
     printf("\n");
     for(j=0; j<4; j++)
     {
       printf(" %d",a[i][j]);
       if(! Prime(a[i][j]) )
       printf("(pr)",a[i][j]); 
     }
     }
}

Here is my improvement!

thebluestar 0 Junior Poster in Training

It should actually be "<= k" rather than less than.

Use 9 as an example and you'll see. The for loop ends and fails to mod 9 against 3, hence returning a value of 1.

Ukie! Thank you very much!

thebluestar 0 Junior Poster in Training
bool isPrime(int num)
{
   if(num < 2 ) return false;
   else if(num == 2) return true;

     for(int i = 2; i < ceil ( sqrt(num) ); i++)
             if(num % i == 0) return false;
  return true;
}

void printPrime(const int Max = 100)
{
     for(int i = 2; i  < MAX; i++)
            if( isPrime(i)) cout << i <<" is Prime\n";

}

When I test your code , it did not work correctly everytime
I also do not find what is the problem , I'm confused in this line
for(int i = 2; i < ceil ( sqrt(num) ); i++)
because if n=9 then it's prime

thebluestar 0 Junior Poster in Training

our isPrime function will return 0 for even-number and return 1 for odd-number because your loop always end at the first loop (because you always return a value at the first loop.)

Try this one instead:

int i;
for(i=2; i<(int)sqrt(n); i++) {
    if(n%i==0) return 0;
}
return 1;

You can also further optimize your code by:

int i;
int k = (int)sqrt(n);

for(i=2; i<k; i++) {
    if(n%i==0) return 0;
}
return 1;

I try it again but the results sometimes true sometimes wrong

thebluestar 0 Junior Poster in Training
#include<stdio.h>
#include<conio.h>
#include<string.h>
//typedef int BOOL;
//#define TRUE 1
//#define FALSE 0

int a[3][4];
int Prime(int *x);
void input();
void printOut();
void checkPrime();

int Prime(int *x)
{
        int i;
        for( i=2; i< (int)sqrt(*x); i++ )
        {
           if( *x%i == 0 )
           return 0;
        }
        return 1;   
}


void input()
{   int i,j;
    printf("Enter element for matrix: \n");
    for(i=0; i<3; i++)
        for(j=0; j<4; j++)
        {
                 printf("element a[%d][%d]: ",i,j);
                 scanf("%d",&a[i][j]);
        }
} 


void printOut()  
{
   int i,j;
   for(i=0; i<3; i++)
   {
      printf("\n");
      for(j=0; j<4; j++)
         printf(" %d ",a[i][j]);
   }  
}   

void checkPrime()
{
     int i,j;
     printf("\nMatrix after check Prime\n");
     for(i=0; i<3; i++)
     { 
     printf("\n");
     for(j=0; j<4; j++)
     {
       if( Prime(&a[i][j]) )
       printf(" %d(pr) ",a[i][j]);
       else 
       printf(" %d ",a[i][j]);
      }
     }
}

int main()
{
    input();
    printOut();   
    checkPrime();
    getch();
    return 0;
}

My source code does not work properly everytime.
I have not found where the mistake was
Please help me
Thanks a lot!

thebluestar 0 Junior Poster in Training
#include "conio.h"
#include "stdio.h"
#include "math.h"

int isPrime(int n)
{
    int i,isTrue=1;
    for(i=2; i<(int)sqrt(n); i++)
    if(n%i==0)
    return 0;
    else return 1;
}

int main()
{
    int N;
    printf("Enter n: ");
    scanf("%d",&N);
    if(isPrime(N))
    printf("prime");  
    else
    printf("Not prime\n");
    getch();
    return 0;
}

here is my source code, but when i test , sometimes it's true sometimes it's false. I don't know what is my mistake
Please help me solve it
Thanks a lot!

thebluestar 0 Junior Poster in Training
#include<stdio.h>
#include<conio.h>
#include<string.h>

int n;
char (*p)[40],*temp;
void Input();
void ABCsorting();

void Input()
{
     printf("How many persons u want to input: ");
     scanf("%d",&n); 
     p=(char*)malloc(n*40*sizeof(char));
     temp=(char*)malloc(n*sizeof(char));
     int i; 
     for(i=0; i<n ; i++)
     {
        printf("String %d: ",i+1);
        fflush(stdin);
        gets(p[i]);
     }
     printf("All strings before sorting: \n");
     /*for(i=0; i<n ; i++)
     {
           printf(" %s\n",*(p+i) );  
     } */
     for(i=0; i<n ; i++)
     printf(" %s |",p[i]);
}

void ABCsorting()
{
     int i,j;
     for(i=0; i<n-1 ;i++)
     for(j=i+1; j<n; j++)
     {
        if( strcmp((p+i),(p+j)) > 0 )
        {
            temp = (p+i);
            (p+i) = (p+j);
            (p+j) = temp;
        }
      /*  if( strcmp(p[i], p[j]) > 0)
        {
            temp=p[i];
            p[i]= p[j];
            p[j]=temp;
        }*/
     }
     printf("\nAfter Sorting: \n");
     for(i=0; i<n ;i++)
     printf(" %s |",p[i]);
}
 
 
int main()
{   
    Input();
    ABCsorting();
    getch();
    return 0;
}

Please help me find the mistake in my above source code
Thanks a lot!

thebluestar 0 Junior Poster in Training

It turns out that this can be done and that
int (*p1d)[5];

is the proper declaration, i.e. p1d here is a pointer to an array of 5 integers just as it was
under the declaration using the Array type. Note that this is different from

int *p1d[5];

which would make p1d the name of an array of 5 pointers to type int.

thebluestar 0 Junior Poster in Training

I'm not sure about the difference between *p[5] and (*p)[5]?
Please help me clarify them?
Thanks a lot!

thebluestar 0 Junior Poster in Training

This is the problem:

In this exercise you have to write a program to manage items in a super market.
Suppose that the data about each item includes:
• Item’s ID: ID of the item, it is an integer which ranges from 1 to 9999
• Item’s type: Its value is:
• 1 if the item is food
• 2 if the item is electrical good
• 3 if the item is household good
• Item’s price

1. Create a structure template that contains data of one item. Then use this template to declare an array
of structures that stores data of maximum 50 items.
2. Ask user to input the list of N items from the keyboard. Then print out the list of items on the screen.
3. Print out the title of the item which has maximum price.
Here is my source code

#include<stdio.h>
#include<conio.h>
#define MAX 50

struct good 
{
   int id;
   int type;
   float price;
};
struct good item[MAX];
int n;
int pos;

void input()
{ char temp[40];
  int i;
  printf("how many items u want to store: "); scanf("%d",&n);
  for(i=0; i<n; i++)
  {
    printf("\nItem %d: ",i+1);
    do
    {
      printf("\n id:");
      scanf("%d",&item[i].id);
    } while( (item[i].id<0) || (item[i].id>9999) );
    printf("\n Type: ");
    fflush(stdin);
    gets(temp);
    if(strcmp(temp,"food")==0)
       item[i].type=1;
       else if(strcmp(temp,"electrical")==0)
               item[i].type=2;
               else if(strcmp(temp,"household")==0)
                       item[i].type=3;
    printf("\n Price: ");
    scanf("%f",&item[i].price);
  }
}

void display()
{ 
  int i;
  for(i=0; i<n; i++)
  {
    printf("Item %d: ",i+1);
    printf("\n id %d, type …
thebluestar 0 Junior Poster in Training
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{ 
  //int a[10]={2,5,1,7,0,10,145,14,15,9};
  int a[10]={1,2,3,4,5,6,7,8,9,10};
  int tem,i=0,j,isTRUE=0;
  for(j=0; j<10; j++)
  {
     if(a[j]<a[j+1])  
     {
       isTRUE=1;
       break;
     }
     isTRUE=0;
  }
  
 if(isTRUE)
 printf("inorder\n");
 else
 printf("ASEorder\n");
  
    getch();
    return 0;
}

Here's my source code about checking an array is ordered or not
But it didn't work properly, but i cannot find any mistake
Help me!
Thank you!

thebluestar 0 Junior Poster in Training

You need a terminating null character, \0. You could add it any number of ways. If you just change "for(i=0; i<n2; i++)" so that "i" goes from 0 to "n2" then it will copy the null at the end of the second string to your new string.

ukie! Thank you very much! I've got it ;)

thebluestar 0 Junior Poster in Training

here is my code

#include<stdio.h>
#include<conio.h>
#include<string.h>

int main()
{
    char A1[100], A2[100],c[100];
    int n1,n2,i,j;
    printf("Enter string A1:\n");
    gets(A1);
    printf("Enter string A2:\n");
    gets(A2);
    n1=strlen(A1); printf("%d ",n1);
    n2=strlen(A2); printf("%d ",n2);
    char *p1=A1, *p2=A2, *p;
    p=(char*)malloc((n1+n2)*sizeof(char));
    for(i=0;i<n1; i++)
    {
     *(p+i) = *(p1+i);
     
     }
    for(i=0; i<n2; i++)
    {
     *(p+n1+i)=*(p2+i); 
    }
    
    int k2=strlen(p);
    printf("%d ",k2); // i try to print out the length of array to know if it's true or not but it's always greater than true length
    printf("%s",p); 
    getch();
    return 0;
}

after I run it, the string printed is added with some unsual charater.
I allocated the memory for string number 3 (p) but actually, it's is greater than needed
I don't know why
hepl me solve it
Thank you

thebluestar 0 Junior Poster in Training

oh! thank you very much!I also found this mistake several minutes ago!
^ ^

thebluestar 0 Junior Poster in Training

You only need one = on your mysql_connect statement.

oh, thank you! I also found this mistake several minutes ago!

thebluestar 0 Junior Poster in Training

here is my source code about login into a web

<?php 
/*
$login=$_POST['login'];
if($login=="Login")
{ */
    $connect==mysql_connect("localhost","root","");

    if(!connect)
    {
       die ('Cannot connect to the database'.mysql_error()); }
  
mysql_select_db("firstdbs",$connect);

$in_user= $_POST['username'];
$in_pass=$_POST['password'];

// To protect MySQL injection
 $in_user = stripslashes($in_user);
 $in_pass = stripslashes($in_pass);
 $in_user = mysql_real_escape_string($in_user);
 $in_pass = mysql_real_escape_string($in_pass);
 
$sql="SELECT * FROM login WHERE de_user='$in_user' and de_pass='$in_pass' ";

$result= mysql_query($sql);
$count=mysql_num_rows($result);  print($count);
if($count==1)
{
echo "dsfaf";
}
else
echo "Wrong something! Please re-login";


?>

but when I open it through the browser it raised some warnings like:

Warning: mysql_select_db() expects parameter 2 to be resource, null given in C:\xampp\htdocs\EX1\page1.php on line 12

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\EX1\page1.php on line 26
Wrong something! Please re-login
I do not know the reason.
Please help me!

thebluestar 0 Junior Poster in Training

I used the boot hiren disk to partition the hark disk. At that time I reduce the capacity of system disk (C) and raise the others.
But in fact, all the programs or softwares that will be installed will be installed in disk C so now I want to resize the C to increase its capacity BUT now I cannot do it, I juct can resize the others not the system disk?
So how can I increase the system disk's capacity ?
Or can I change D disk (its capacity is very large) into C disk (mean after doing that D will be the system disk)? I can do it with which software?
Help me ! thank you!

thebluestar 0 Junior Poster in Training

yeah, I know that but why we should use the temporary variable to save the value before passing it to array's element?
Here, I means the advantage or strength when using the temporary variable.
help me understand more clearly! don't be peevish! thanks a lot!

thebluestar 0 Junior Poster in Training

No no I don't understand what he means or I don't understand his answer. :(.
Or he means that both two above source code is correct and they are the same?

thebluestar 0 Junior Poster in Training

I don't understand your idea?

thebluestar 0 Junior Poster in Training

Here is my source code of inputting and print the matrix:

#include<stdio.h>
int main(void)
{
    unsigned int m,n;
    int a[10][10];
    int i,j;
    int temp;
    printf("Plz enter the number of rows of Matrix:\n");
    scanf("%d",&m);
    printf("Plz enter the number of columns of Matrix:\n");
    scanf("%d",&n);
    
    printf("Enter elements for the Matrix:\n");
    for(i=0; i<m ;i++)
    for(j=0; j<n; j++)
    {
             printf("Element[%d][%d] is: ",i,j);
             scanf("%d",&temp);
             a[i][j]=temp;
             }
    printf("The Matrix is:\n");
    for(i=0; i<m ;i++)
   {
       for(j=0; j<n ; j++)
            printf("%d ", a[i][j]);
       printf("\n");
   }
    getch();
    return 0;

I don't know the difference between the direct entering value for element of matrix:

printf("Enter elements for the Matrix:\n");
    for(i=0; i<m ;i++)
    for(j=0; j<n; j++)
    {
             printf("Element[%d][%d] is: ",i,j);
             scanf("%d",&a[i][j]);
           }

and through the temporary like code before:

printf("Enter elements for the Matrix:\n");
    for(i=0; i<m ;i++)
    for(j=0; j<n; j++)
    {
             printf("Element[%d][%d] is: ",i,j);
             scanf("%d",&temp);
             a[i][j]=temp;
             }

Because when running both of them runs very well without any bugs.