kekkaishi 18 Junior Poster

eduardc,
Your code looks to be OK. As Karthik suggested, try executing the line (select * from Products) in phpmyadmin (or your sql dbms).

Also, I suggest using mysql_error() in your codes to identify the exact error the database is returning. That is,

mysql_select_db("eduardli_company", $con) or die(mysql_error());


mysql_query ("INSERT INTO Products (Description, Price, Quantity) 
VALUES ('$description', '$price', '$quantity')") or die(mysql_error());

$q="select * from Products";
$result = mysql_query($q,$con) or die(mysql_error());

Regards.

karthik_ppts commented: useful post +3
kekkaishi 18 Junior Poster

Escape forward slash.

.. *)\[\/\]/s', '<div>\\1</div>', $string); Hope this would help you to carry on.

RoyalElite96 commented: Thnak you, that worked! +1
kekkaishi 18 Junior Poster

Is it exactly the same error as before. Also, one I missed the first time.

if (mysql_num_rows($verify_topic) < 1)[line 23]
//$verify_topic is a string. Not a mysql result set.

Hope this helps.

kekkaishi 18 Junior Poster

one more thing i just rmbrd to check. its if uve define textnumber before using it. it seems not so u have to make the below changes.

//CHANGE
textnumber = convertIntegerToWords(userNumber);
//TO
String textnumber = convertIntegerToWords(userNumber);
kekkaishi 18 Junior Poster

1. im assuming that ur main class is JUST like the way u posted. i.e

public static void main(String... Args)//if so this is incorrect. it must be

public static void main(String[] args) //an array of arguments u shud pass

2. this is ur code

if (userNumber == 0)
	         System.out.print( "Thank you for playing! " + "Good bye! ");	
                 break;
//change it to 
if (userNumber == 0){
	         System.out.print( "Thank you for playing! " + "Good bye! ");	
                 break;
}// u had this correct the first time

3. chk below

else if (userNumber > 0 && userNumber< 10){
	         //then print out numbers as words using convertIntegerToWords(int numWord)	
                 textnumber = convertIntegerToWords(userNumber);//notice the change. use ';' to mark the end
                 System.out.print(" Your integer is " + textnumber);// semi-colon
 }//end of else-if
              else if (userNumber < 0 || userNumber > 9){ //
                 System.out.print( " The integer you entered is not between 1 and 9"); //semi-colon
 } //try to use parenthesis {} to enclose if blocks and else if blocks. 
              userNumber = input.nextInt(); //userNumber without int

btw, peter gives good advice.

hairpull commented: This was well laid out for a beginner to understand. TY for your time. +1
kekkaishi 18 Junior Poster

ur convertIntegerToWords(int number) function should return numWordString. (if number is 1 nuwWordString would be one. also for each of the case add break so that it would break as soon as numWordString as a value
eg:

case 1:
  numWordString = "one;
  break;
case 2:
  numWordString = "two";
  break;
//ans so on

make these changes and call to ur function after this line and pass it userNumber

else if (userNumber > 0 && userNumber <= 9) //also change this to else if userNumber > 0 && <= 9) to include 9
convertIntegerToWords(userNumber)//call to ur function like this. u do not need to include int. coz uve already defined the variable and ur passing the value assigned to that variable to ur function

also, to keep the program running until the user enters 0, inside the while loop, after the number word is printed out, repeat the line

userNumber = input.nextInt();

hope this helps.

Edit:
note that the else if conditions must be like this
else if (userNumber > 0 && userNumber <= 9)

kekkaishi 18 Junior Poster

try changing line 15 to thia

<!--<img border="0" src="/images/2173453.jpg" alt="koria girl" width="304" height="228" />-->
<img border="0" src="images/2173453.jpg" alt="koria girl" width="304" height="228" />
kekkaishi 18 Junior Poster

also, here is a little something for ur reference. this script is working and use this as ur reference.

//activatePage.php
<?php

//mysql connections and all...

if(array_key_exists('id', $_GET)){
    $id = $_GET['id'];
    $acCode = $_GET['actCode'];
    
    $sql = mysql_query("SELECT * FROM members WHERE userId={$id}");
    
    if(mysql_num_rows($sql)==0){
        echo "user does not exist";
    }else{
        $row = mysql_fetch_array($sql);
        if($row['activated']==1){
            echo "already activated";
        }else{
            if($row['actCode']!= $acCode){
                echo "act code mismatch";
            }else{
                mysql_query("UPDATE members SET activated=1 WHERE userId={$id}");
                echo "activated";
            }
        }
    }

}else{
    ?>
<a href="?actCode=aabbccdd&id=1">Activate user1</a>
<a href="?actCode=bbcceefd&id=2">Activate user2</a>
<?php
}

?>

//here is the db table to go with the above
CREATE TABLE IF NOT EXISTS `members` (
  `id` int(1) NOT NULL AUTO_INCREMENT,
  `activated` int(1) NOT NULL DEFAULT '0',
  `actCode` varchar(250) NOT NULL,
  `userId` int(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `members` (`id`, `activated`, `actCode`, `userId`) VALUES
(1, 1, 'aabbccdd', 1),
(2, 1, 'bbcceefd', 2);
Tehim commented: Really helpful thanks :) +1
kekkaishi 18 Junior Poster

u needa return the sorted array from the rotateRight function

public static int[] rotateRight(int[] array){

and at the end of the function

return array;

and in the main

list = rotateRight(list);

hope this helps

kekkaishi 18 Junior Poster

if i may add in, can't u just do this?

public static void main(String[] args){
        int sum=0;
        for(String s: args){
            sum += Integer.parseInt(s);
        }
        System.out.println("Sum: "+sum);
    }
kekkaishi 18 Junior Poster

just thought id also add in a bit.
remember that mysql fetch array returns only one row each time the query runs, first run returns first row of the mysql resource, the second run second row and so on and returns a false if there is no more... so the cleanest way to go about is to use a while loop as u did IF u r fetching from DB. As network18 said, the best way is to practice and 'explore' be it foreach loop or anything else :)

rouse commented: Kekkaishi as good energy and insight +2
kekkaishi 18 Junior Poster

Ok so im building a level editor for this game. What the code i cant working does is, when the button is clicked it should get the selected cell from the jtable and set a value for it. However, for some reason I cannont get it working. Here is the code:

for (int y = 0; y < 30; y++)
					{
					        for (int x = 0; x < 30; x++)
						{
							if(wallChooser.isCellSelected(y, x));
							{
								wallChooser.getModel().setValueAt(value, y, x);
								System.out.println("works again" + x + " " + y);
								value = "";
							}
					        }
                                           }

when i run the application for some reason it just print works again for every single cell. But the selected cell does not get the value.

Please help,

thanks
jakx12

how about when you removed the semi-colon from if(wallChooser.isCellSelected(y, x));

kekkaishi 18 Junior Poster

i dont think im getting anywhere with this, im just not knowledgable enough about php at the moment, i literally only have about 4 weeks of php knowledge.

aany help would be much appreciated

c if this works.

//echo "<td width='20%'>".$result[stock]."</td>";
//instead of this, try the following
echo "<td width='20%'>"; 
if ($result['stock'] == $qty){
   echo $exact; 
}
echo "</td>";
dandixon commented: really took the time to help me out +1