Stefano Mtangoo 455 Senior Poster

Hi All,

I have a PHP code which do some changes to the POST variables it receives and redirect the page to some other page. This PHP code was initially designed to work without Ajax. So there wasn't any problem with the redirect function and it perfectly handles the POSt variables and redirect the user to another page.

So now I want to use the same PHP code with Ajax... :)
I tried it and and it did not gave me the results I was expecting. Problem is with the redirect function. Other PHP lines execute perfectly fine( it stores some data in the database).

So is there any way to ignore the redirect call or just to filter out the redirecting url into a javascript variable ?

Thanks in advance for taking some time to read this

I would recommend JQuery library for easy AJAX calls. With JQuery, you just select the element (Let say a Div) and clear it. then AJAXically get the content of page you want to redirect using load() function. Read the $.post, ajax() and load as well as selectors

Stefano Mtangoo 455 Senior Poster

I want to pass a character not a string

Isn't Character a string with length 1?

Stefano Mtangoo 455 Senior Poster

Check W3school

Stefano Mtangoo 455 Senior Poster
Stefano Mtangoo 455 Senior Poster
DROP tabble_name ;

don't condemn me, that is from heading ;)
Now, seriously PMC have got it!

Stefano Mtangoo 455 Senior Poster

MY question is,
like we do for integer and float,
Integer.parseInt(args[0])
Float.parseFloat(args[1])

How do we take character input from command line ?

Those are methods to convert stuffs since command args are passed as Strings (i.e String[]).
So to get a string it is as easy as

String argX = args[i];//to get the i-1th argument
Stefano Mtangoo 455 Senior Poster

Don't use database/table name in displaying result

while($rows = pg_fetch_all($myresult))
{	
	echo "<pre>";
	echo "<div>".$rows['timestamp']."</div>";
}
Stefano Mtangoo 455 Senior Poster

also see this

Stefano Mtangoo 455 Senior Poster

Thank you guys. I am learning and I appreciate your help. Sometimes the challenge is to know what to even call your search in Google.

I got #1 of my question to work, but I am still struggling with #2.

I have tried many things but here is what I have now. Database is called playerdb and the table I want to show data from is also called playerdb.

<? php
$result2 = mysql_query("SELECT UPDATE_TIME FROM playerdb AND TABLE_NAME = 'playerdb'");


echo "Last updated on : $result2";


?>

I appreciate any help.
Cheers

You need to add column in your table that will store last update time that will be modified each time the row get modified

Stefano Mtangoo 455 Senior Poster

You can search this forum for even more examples.

I second that, this is kind of FAQ, and a lot of practical examples.
Just pick one and post any problem you get (There is nice example from PHPMyCoder)

Stefano Mtangoo 455 Senior Poster

what does this mean:

action="<?=$_SERVER?>"

and this:

value="<?=$data?>"><?=$data

<?=$_SERVER?> refers to the same file, that is the same file currently being executed. suppose the code is in index.php, when you call <?=$_SERVER?> it means you are calling index.php

value="<?=$data?>"><?=$data fills html value with data from array with index id and name

hope you get it :)

Stefano Mtangoo 455 Senior Poster

Thanks Steve!
It is a great framework, though I am embarrassed to say that I haven't worked with it that much either. :D
Someone on the PHP form has to be a CI guru. If there isn't and vizz has a question about CI, I guess we have some reading to do...
-PhpMyCoder

EDIT: It's been so long since I've been on Daniweb, I almost forgot how strange the smilies looked!

I will be making Big PHP project in few months to come and I will use CI so slowly I'm getting familiar with it. Controllers/Views are Just breeze and I'm learning how to do "messy" things in Models.

Stefano Mtangoo 455 Senior Poster

Don't bother of Ajax Code with pure JS.
There are a lot of libraries out there that simplify JS.
So Unless you are learning JS, pick one and use the simplified AJAX calls.
My favo is JQuery

Stefano Mtangoo 455 Senior Poster

If I may add my ten cents, I believe that CodeIgniter.com has a great 20 minute tutorial on creating a basic blog. .........................

For the purists out there, I'm not endorsing CI as a start to PHP. I believe it's much better to learn and be comfortable with PHP basics & OOP before using a framework. In this case, I think a framework could help illustrate relationships and basic functionality.

All the Best,
PhpMyCoder

I second PhpMyCoder on CI once you get passed the basic PHP and OOP
It is great framework thoug I have barely scratched the surface

Stefano Mtangoo 455 Senior Poster

how do i escape the _POST or _GET? i have resarchd but dont get it, thanks

I'm yet to find mysql_real_escape_string equivalent for odbc.
May I know why are you troubling with ODBC while MySQL is free and very capable and is smoothly supportted in PHP?

Stefano Mtangoo 455 Senior Poster

Glad we helped :)
Mark it solved then!

Stefano Mtangoo 455 Senior Poster

Hey guys
I've had the same problem and by looking at lots of different ways to solve the problem i have found the solution. I'm not sure on the specific reasons and stuff but basically, the error only pops up if you had not ended the "while" command. So i think the code keeps repeating in that socket or something. Just remember before you close the python window when you go to test your code, write a code to end the "while" command.(it will tell you that the program is still running and if you want to kill it)
:P

More than year old thread Lol!

Use VIDLE that comes with VPython or alternatives already mentioned

Stefano Mtangoo 455 Senior Poster

There are no validations yet needed unless you think i need it.

Beware of SQL injections. At least escape your GET/POST stuffs before using them

Stefano Mtangoo 455 Senior Poster

If it works for Dynamic pages then it should not be hard for static. Just rename your pages to something like story1.htm, story2.htm et al and create that dynamically, something like below. This is not working code, so implement in Murali's code.
But why would it be "strictly" Static?

i = 1; //story1
include("story".i);
Stefano Mtangoo 455 Senior Poster

No probs, Yeah proudly a kiwi haha

Why New Zealanders calls themselves Kiwis? Is that a nation symbol like giraffe is for my nation?

Stefano Mtangoo 455 Senior Poster

This is the best tutorial I have ever found on PHP, newwbie-sh speaking

Stefano Mtangoo 455 Senior Poster

Add redirection after inserting

if(isset($imp)){
	
	foreach($imp as $a => $b){
	$query_all = "INSERT INTO test (emop_id, implementor, steps, start, finish, duration, status) VALUES ('$id', '$imp[$a]','$step[$a]','$start[$a]','$finish[$a]','$duration[$a]', '$status[$a]')";
	mysql_query($query_all) or die('Error with TEST query, query failed:'. mysql_error());
	}
  header(Location:"home.php");//do redirection here
}
Stefano Mtangoo 455 Senior Poster

What is contents of include "wconfig.php";?
If you search for error message, you will find the answer.
But to get the flavor of answer see links below

http://www.phpbuilder.com/columns/anonymousjoe20080225.php3

Stefano Mtangoo 455 Senior Poster

After inserting redirect to another page which have link to insert page
That is page home.php have link to insert.php if one click link it takes him to insert.php and after inserting redirect to home.php

Stefano Mtangoo 455 Senior Poster

Mark it solved

Stefano Mtangoo 455 Senior Poster

Would you summarize your question, I have failed to understand it

Stefano Mtangoo 455 Senior Poster

I tried but could not find any other mistake which could have caused runtime error.. Can you please help!!

Use debugger to step through your code and you will find errornous line which will be easy to fix.

Also get yourself Update IDE. I think DevCPP died many years ago!
get CodeLite, CodeBlocks, VC++ Express or Active version of DevCPP called wxDevC++

Stefano Mtangoo 455 Senior Poster

Sounds like spam installed in your server and started sending flood of stuffs!
Have you got massive mail sending like mailing list?
How long have you hosted there?

Stefano Mtangoo 455 Senior Poster

I found VB Somehow confusing to me as beginner (Check my first posts), and I moved on with Python and PHP and then C++. I think the only confusing points is when you come to pointers. They are somehow confusing but the other stuffs are somehow simpler.

Many says VB is easy, are referring to GUI drag and drop. But that is even available in C++ using libraries (wxWidgets with Dialog blocks or wxSmith or wxFormbuilder: QT with QTCreator: GTKmm with libglade et al)

So I hope it is not that harder ;)

ZlapX commented: sucks balls +0
Stefano Mtangoo 455 Senior Poster

I have made simple googling as I'm yet to do any chat app.
But basically here are steps
1. Create server.
2. Create client (Both are sockets classes)
3. server is listening to a port
4. Once request is made by client, server creates thread to serve that server and add the ID/Name of the accepted connection in list of active clients
5. Server will have a method to connect two threads in active list

That can be done in many way but I would advise you to start with understanding ABC of TCP/IP then Java sockets tutorial and then, choosing design to implement will be easier

Stefano Mtangoo 455 Senior Poster

I would not bother with JLNP for my any desktop apps unless there is compelling reason to use it (Which I don't see for now)

Stefano Mtangoo 455 Senior Poster

JNLP uses Java webstart and it is better to use jar files for desktop application,
use javac compiler to make class files that can be bundled into jar file.

IDEs like Netbeans or Intellij Idea will easy your work

Stefano Mtangoo 455 Senior Poster

And also this works but since it is assignment the use the second one to convince your prof. The reason is here

ArrayList<Integer> numbers = new ArrayList<Integer>();
List<Integer> numbers = new ArrayList<Integer>();
Stefano Mtangoo 455 Senior Poster

Why not use normal Java Compiled files even Jar files?
Are you making an applet or just Desktop app?

Stefano Mtangoo 455 Senior Poster

Mark it solved then ;)

Stefano Mtangoo 455 Senior Poster

Just to add, the program you have (i.e shown below) isn't supposed to print anything in case user enters any number greater or equal to 1. It should just print "end"

int num,count = 1;
cout<<"Please enter a number: ";
cin >> num;
while(count > num){
cout << " " << count;
count = num + 2;
}
cout <<"end";
Stefano Mtangoo 455 Senior Poster

change this line

int num,count = 1;

to

int num;
int count = 1;

It will be good to initialize something like

int num=0;

but it is completely optional

Stefano Mtangoo 455 Senior Poster

Since you want to be geekish
start here

Stefano Mtangoo 455 Senior Poster

Nope, you reversed things,
while(1 > 10){
is false and the loop doesnt run.
try something like

cout<<"Please enter a number: ";
cin >> num;
while(num>count){
Stefano Mtangoo 455 Senior Poster

Get CodeLite or CodeBlocks which come bundled with MinGW. But since you dont need IDE just grab MinGW and Notepad++ and Have your Windows+R type cmd and there you go!

Stefano Mtangoo 455 Senior Poster

Or you could use code blocks.

Personally, why have an IDE for c++/c.

This is linux, why aren't you using vi with g++ from the command line!

For small projects I agree. But for Big project, it becomes tedious. For example with CL you have completion, refactoring, automatic add include, code beautification, SVNing, GUI and many others...So then it boils down to personal convenience

Stefano Mtangoo 455 Senior Poster

Sure, Eclipse is made modular but CL was designed specifically for C/C++ so it outperforms and eclipse. Plus CodeLite is coded in C/C++ and Eclipse in Java ;)

Stefano Mtangoo 455 Senior Poster

or Just chmod the projects directory to 777
that is:
sudo chmod 777 folderName/

Stefano Mtangoo 455 Senior Poster

Hello download CodeLite and use it, it is specifically designed for C/C++ with focus only on that. As per your problem, where did you put project files?
try this:
create folder under Home that is
cd and press return key
then cd Documents/
mkdir Projects
cd Projects/
mkdir CandC++
then when creating new workspace in codelite, create it under /home/your_name/Projects/CandC++/workspace_name

Voila!

Stefano Mtangoo 455 Senior Poster

I suggest you use GCC and CodeLite

Stefano Mtangoo 455 Senior Poster

I always delete the .nbi,.netBeans,.netbeans-derby ,.netBeans-registration folders
and empty any server folders when re-installing netbeans. On re-install it will tell you if a folder needs to be empty.

And revo will do that for you :)

Stefano Mtangoo 455 Senior Poster

Use revo uninstaller to remove it. Google it!

Stefano Mtangoo 455 Senior Poster

did you read sos post?
It explains all those.
Are you doing if on independent conditions? It will not fully work.
re-read sos post and get the point

Stefano Mtangoo 455 Senior Poster

I have not understood what you want to do. Can you post that chunk of code?

Stefano Mtangoo 455 Senior Poster

Mhh! What do you want to do?
Something like this?

<%
            if (request.getAttribute("login") == null) {
                response.sendRedirect("/login.jsp");
            }
            else if (request.getAttribute("cash") == null) {
                response.sendRedirect("/no_cash.jsp");
            }
%>

you cannot redirect the same page twice or the two conditions *MUST NOT* happen at the same time!