Why? What is that you are exactly trying to do?
hairpull commented: This was well laid out for a beginner to understand. TY for your time. +1
Tehim commented: Really helpful thanks :) +1
Why? What is that you are exactly trying to do?
Just out of curiosity.. Did you have your Date field defined as a type 'DATE' in the first place?
On another note, it is good practice not to use mysql keywords while naming your tables or columns for that matter.
Maybe you have already tried this or maybe I still do not understand your question, but I will post this anyway, you know, just in case...
foreach($datasq as $key=>$val){
echo "For part no". $key. "<br />";
echo "qnty is: ". $val['qnty'];
}
EDIT: @Nichito sorry mate. did not see that.
Is Date covered in single quotes? If so it should not be.
$query="SELECT JourneyID FROM Journey WHERE 'Date' //no single quotes
However, . date("Y-m-d", $searchDate) should be covered in single quotes. i. e.
$query="SELECT JourneyID FROM Journey WHERE `Date` = '" . date("Y-m-d", $searchDate)."'";
Hope this solves your issue.
Maybe, foreach part_no get qnty and weeky....
hmm.. well there is one (probably) a dirty solution I can think of. That is to create a result array and after each query push the result, if it returned any, into that array. While doing so also I would suggest you to use alias to rename the columns so that it'd be easier for you later on while manipulating the result array.
Here's an example of what I am suggesting.
$resultArray = array();
$qry = "SELECT ....";
if(mysql_num_rows($qry) > 0){
while($row = mysql_fetch_array($qry)){
array_push($resultArray, $row);
}
}
//repeat this for the three queries.
//Now result_array will be a two dimensional array. to manipulate it you could use something like
foreach($resultArray as $secArray){
foreach($secArray as $key=>$value){
//create anchor link maybe.
echo "Key:".$key.": Value".$value;
}
}
Again, this probably is a dirty solution. So lets hope someone else would suggest a better one. Anyhow, good luck mate.
Also, here's one link I came across upon a google search.
http://kedar.nitty-witty.com/blog/search-through-all-databases-tables-columns-in-mysql
Have a look at it, maybe it'll be of help...
UNION requires that all the tables have the exact same number of columns. i.e. If your first result set contains 3 columns (like the one you already have), then you need to have all 3 columned tables. It doesn't matter if the result table is created using joins.
In your code, the last two statement creates a result set containing tables of 2 columns. If b.Description in your first statement is really important, then why don't you include it in the other two statements also? Otherwise, eliminate it from the first.
EDIT:
.. displaying text as opposed to the Code which is being stored on the one table.
When you rename your columns using AS you could those name to refer to that column Say, for example:
$qry = "SELECT column_name AS c_name FROM sometable";
$res = mysql_query($qry);
while($row = mysql_fetch_array($res)){
echo $row['c_name']; //echos the value stored in column_name
}
Hope this helps and good luck.
The pages seem to be navigating to the right pages however the page does not appear i get
:Oops! This link appears to be broken.without the above script active the page seems to load fine
Is this the entire code? If not, you need to define $uid.
header("location: goldaccount.php?id=$uid"); //$uid is uid stored in session I suppose...
Also, I wonder if the other pages are in the same directory as this page. If so, do you get an oopsy for 'myacount.php'?
line 11 and line 13: you are doing comparison so there should be double equal operators.
else if ($_SESSION['type']== 1){ //single = means you are assigning
Apart from that the code looks ok.
Hope this helps.
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.
How about joining all the tables together using UNION and renaming columns using AS keyword so that you could identify from which table which result is from.
EDIT: link to MySQL UNION
Either define ArrayList list globally or make printHand accept it as a parameter.
1. Check if topic_id is set. Execute the query only if it is set.
2.
$topic_info = mysql_fetch_array($verify_topic_res) [line 29]
Where did $verify_topic_res come from?
Hope this helps.
Maybe this will help you.
A long/long is long. long/int is long. double/int is double. double/long is double. long/double is double ... and so on.
Apply this to line 16 of your code.
Hope this helps.
You are posting the input values so you have to use $_POST[name of the input field]. i.e.
//in your form
<input name="mobile" type="text" id="mobile" value="<?=$mobile_no?>"
//in your php script, to get the value from this input field
$value = $_POST['mobile']; //$_POST['mobile'] because <input name="mobile" ..>
Also, you need to add an action to your form. It seems that you are trying to use the same file for displaying as well as processing the form. I suggest you go through this tutorial before proceeding with your coding.
Hey, I am no expert in regexp but quite recently I had the same problem with escaping a $ sign. Just like you I used a single backslash to escape it and when it did not work I experimented with double backslashes and it did work then. I do not know exactly why. I did try to find out why but I'm afraid I was unable to get a satisfactory answer. I did however got introduced to preg_quote function that adds a backslash to every special character. There seems to be some issues in the function but for me it has worked without an issue. Even the $ sign issue after being passed through the function seems to be working. I hope this answer is of some help to you. :Dhttp://my2.php.net/preg_quote
$_SESSION is a super-global variable you could use to store temporary data. It is an associative array and 'views' indeed could be said as an index. Instead of having numeric values as indexes as in normal arrays, in associative arrays you could have words as indexes. So in this case, $_SESSION = 1 means that you are storing 1 in $_SESSION array under index 'views'. If you perhaps want to store 2 in another name you could simply say $_SESSION=2; Or, if you want to assign 3 to 'views' you could just say $_SESSION = 3. Later on, if you want to call these, you could just call $_SESSION to get the value 3 (because 3 was stored later) and $_SESSION to get the value 2.
As paulrajj, I also recommend that you read about PHP sessions. This line would also be a helpful link to learn about sessions. http://www.tizag.com/phpT/phpsessions.php. I also recommend that you read about associative arrays. http://www.tizag.com/phpT/arrays.php
Hope you understood and hope this was of help.
In your php code, the if block that echos the numbers is inside the second for-loop while it needs to be outside.
One easy way to do this is as below.
int[][] Board = new int[15][15];
for (int j = 0; j < Board.length; j++) {
System.out.print((j < 10) ? " " + j + "\t" : j + "\t");} //use tab (\t) to introduce space with constant width.
for (int r = 0; r < Board.length; r++) {
if (r != 0) {
System.out.print((r < 10) ? "\n " + r : "\n" + r);
} else {continue;}
for (int c = 0; c < Board[r].length - 1; c++) {
System.out.print("\t__");}
System.out.println();
}
Alternatively you could read about formatted printing.
Hope this helps.
oh! what you are doing is this.
change = 4.0;
numTens = change/1000; //i.e. 4/1000
change = change - (numTens *1000); // change = 4 - (4/1000 * 1000); //this would make change to be 0 because 4/1000 * 1000 is 4. (original value of change). 4-4 is 0.
now, there is a problem with your logic don't you think? Try to address this issue.
hope this helps.
Did you set your JFrame2's visibility to true?
Change type of variables between line 44 and 50 from int to float. If you want to cast from float to int then you should do like this
int numTens = 0;
..
numTens = (int) change / 1000; //since change is float cast needed.
hope this is what you are looking for.
You could manipulate string to see if it contains letter 'V' at 10th position (9th if you consider that the string starts with index 0, 1... and so on). One way to achieve your goal is,
$num = "123456789V";
if(strlen($num) == 10){
echo "OK. length is OK."; //assuming that you would want to know if the length is 10
if(strpos($num, "V") == 9){ //now checking if "V" is at 9th position. since strpos returns index, 10th position is at 9th index.
echo "V is at 9th position";
echo "now checking if the rest is all numbers";
$numb2 = substr($num, 0, 9); //here, its creating a substring from $num string. the new string would contain characters starting at index 0 and then upto 8th index. 9 here means that the length of the new string should be 9. (from 0 - 8 it is 9)
if(is_numeric($numb2)==true){ //use is numeric method to see if the new string contains all numbers
echo "the rest are all numbers";
}
}
}
hope this helps.
I don't think if its possible to generate popups with only PHP. You can use Javascript to achieve this.
One way to do it is to have a main container. This could be a div or a table. Then set the border using css.
Eg:
<div id="main" style="border: 1px solid #333333"> <!-- inline styling. you could also do this in a separate css file. -->
....
</div>
Its the same for tables. Replace div with table tag. But, div is more lightweight.
To include a table within a table, create the new table inside <td> tag like so:
<table id="main">
<tr>
<td>
<table><tr><td> </td></tr></table>
<td>
</tr>
</table>
Hope this helps.
line 11, closing bracket is missing.
//mysqli_select_db($this->link, $this->db_database
mysqli_select_db($this->link, $this->db_database);
line 19:
try changing it from
//$sql = "select * from '$table'";
//TO
$sql = "select * from $table"; //without single quotes. table name do not need to be enclosed with single quotes.
//OR
$sql = "select * from {$table}";
hope this helps.
I am looking at that line again, should the values not have ' at beginning and end?
Like this
('$uid,$pid,$message')";
Oh boy, you must excuse me if this was not helpfull, as I am also learning this stuff, and may not know what I'm talking about. Rather leave this to be answered by someone who knows better, if I am wrong with above suggestion.
I dont think. As shanti said, only varachar (or text) characters needs to be enclosed in quotes. So, in this case, as shanti, it can be assumed that user and poster are int fields (since $uid and $pid can be assumed as being ids and hence ints). So, only $message needs to be enclosed with single quotes.
..($uid,$pid,'$message')";
Note that if user or poster is varchar, they also need to be enclosed with single quotes.
Knowing about JMenus might help you. Here is Sun's/Oracle's tutorial on how to use menus. http://download.oracle.com/javase/tutorial/uiswing/components/menu.html
Hope this helps.
It seems that the error lies in your database.php file. So, perhaps you could include the source of that file.
It might help to know what you have assigned to $trade_users_query, $trade_items_query and $quantity_query.
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);
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.
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)
cant u just use the default date class? or Calendar class? (or both together?)
could u post the error message?
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" />
if i may add in, a couple of points. (refering to ur original code)
1-
$con = new mysqli("internal-db.s110820.gridserver.com","db110820","Solved!2$$"); //is only the connetion. the database needs to be selected
$con->select_db("dbname");
2- the way u've coded mysqli_stmt::num_rows wont work i think. u first need to store the result if u wanna use num_rows. otherwise num_rows will return 0 always. eg usage:
$qry = "select * from login where trim(email)='{$email}' and password = '{$pass}'";
$result = $con->prepare($qry);
$result->execute();
$result->store_result();
if($result->num_rows){
.
.
//as ardav suggested id also suggest to use num_rows>0 or num_rows==1
}
u could also use the code u r using, but instead of num_rows, use affected_rows
i.d
if($con->affected_rows ==0){
//do task
//BUT still u needa select the db.
}
hope this helps.
if i may ask, what are u trying to do exactly?
if u want to count the number of rows a mysql result set carries, you could use mysql_num_rows function.
$sql = "SELECT * FROM table WHERE id={$id}";
$number_of_rows = mysql_num_rows($sql);
btw, is $id a numeric value. if yes, then
$check_id = mysql_query("SELECT * FROM `members` WHERE `id` =".$id) or die(mysql_error()); //remove single quote
//OR
$check_id = mysql_query("SELECT * FROM `members` WHERE `id` ={$id}") or die(mysql_error());
could solve ur problem
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);
ok since uve echoed the gets, althoughit should work, just check ur database to see if there is data (an activation code) for that id. the id in the link that is. if there is, try changing ur line 25 to the suggested.
//$check_id = mysql_query("SELECT * FROM `members` WHERE `id` = '$id'") or die(mysql_error());
$check_id = mysql_query("SELECT * FROM `members` WHERE `id` = '".$id."'") or die(mysql_error());
maybe this could work for ye.
$sql = "SELECT * FROM blocks WHERE sid={$id}";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$bid = $row['sid'];
echo $row['sid']."<br />";
$x = true;
while($x = true){ //use a boolean to continue loop
$sql = mysql_query("SELECT * FROM blocks WHERE id= {$bid}");
if(mysql_num_rows($sql)==0){
$x=false; //if there is no box with id of the previous box then the result set is null. so this is the end of the link betn the boxes. so make $x false and break the loop.
break;
}else{
$row = mysql_fetch_array($res);
echo "box id: ". $row['sid']." and Id: ".$row['id']."<br />";
$bid = $row['sid']; //always updating $bid so that when the loop starts again $bid is a new one and the query within the loop always selects a new result
}
}
hope this helps
u could use the way i suggested earlier before inserting also. then theres all php. write a function in php to encrypt the password. u could use md5 or sha1 or stuff like that. heres a quick sample.
function encrypt($string){
$salt = "abcd";
$string = md5($string);
$encrypted = $salt.$string;
return $encrypted;
}
hope this helps
encrypt the password received from input before comparing. that is for eg:
$pass = $_POST['pass']; //assumed u r using post
$pass = encrypFunction($pass); //assumed that u r using a function to encrypt the password and that the function is, say, encrypFunction($s);
//$pass is now encrypted so now ud be comparing two encrypted passwords
$q = mssql_query("SELECT pass FROM user_table WHERE pass='".$pass."'");
hope this helps
you want something like this:
$i=1; while($i<10) { if($i==1) { print "id : "+$i; echo "<br>"; } else { echo "id : "+$i+" , "; echo "boxid : "+($i-1); echo "<br>"; } $i++; }
i wanted to suggest this method but the other example provided stopped me from doing so.
box 1 has id 239
box 2 has id 456 and boxid 239,
box 3 has id 123 and boxid 456
here the id is random. it is not a consecutively incrementing number. thats y i asked if this is a problem concerning arranging a set of boxes by of course referring to boxId...