Stefano Mtangoo 455 Senior Poster

Netbeans is good but it eats good amount of resources. I found Notepad++ a good choice though it isnt IDE. I'm configuring aptana right now and it seem to be good. I was searching for portable IDE to move with in stick and I have just made it portable and I'm installing plugins.

Also you can check young codelobster PHP edition.

Stefano Mtangoo 455 Senior Poster

Hi All,
I'm starting learning Java and I need online tutorial.
I have benefited a lot from site www.zetcode.com and I would like to have summarized and "well-for-beginner" tutorial. Many of Java tutorials I find are a bit confusing to newbie like me.

I'm not new to programming (a lot of Python, little of C++)
Thanks for your help :)

Stefano Mtangoo 455 Senior Poster

If you used an INT(11) data type I belive the max ID would be 4,294,967,295 which would be about the total online community of the entire planet, so a very large user base :-)

I think you'll hit other server side issue long before you hit the ID limit, i.e disk space, too many concurrent users etc.

Hope this helps you sleep easier.

Thanks all guys. It have been alot of learning and fun:)

Stefano Mtangoo 455 Senior Poster

Good explanation. But what happens after a deleting and adding let say millions of user? Wont Database become clogged?

Stefano Mtangoo 455 Senior Poster

Hi all,
When you add integer ID primary key auto increment, it automatically makes ID for you. But I was pondering on what happens after deleting a record. Does the server automatically adjust all IDs for you or it remains un assigned?

For example, I have inserted as follows
+------------+-------------+
| 1 | Orange |
|-------------+-------------+
| 2 | Banana |
|-------------+-------------+
| 3 | Mango |
|-------------+-------------+

If I delete Banana, what happens to ID no 2

Stefano Mtangoo 455 Senior Poster

such check needs knowledge in regular expression. what I know is that you can validate any pattern you set in your Regexp. So check it out for I'm not well versed in it.

May be look at these:
http://lmgtfy.com/?q=regular+expressions

Stefano Mtangoo 455 Senior Poster

TinyMCE has a plugin to handle images:

http://tinymce.moxiecode.com/plugins_imagemanager.php

Thanks, but that needs some $$. I have got Ibrowser and works fine.
Thanks alot!

Stefano Mtangoo 455 Senior Poster

Hi All,
I'm trying to make simple CMS and can populate my HTML (generated by TinyMCE editor) to my database. I can retrieve them as well. Now I want to add image support to My editor. What are the tricks necessary?

Thanks a lot :)

Stefano Mtangoo 455 Senior Poster

Thanks!

Stefano Mtangoo 455 Senior Poster

What version of Python do you have?

Stefano Mtangoo 455 Senior Poster

What about making your own CMS to beat Joomla! or Drupal. Or taking Wordpress out of Business? or May be a hotel CMS.

Stefano Mtangoo 455 Senior Poster

Yeah, alot!
But one more question, how do I create such url?
Should I append an ID right when I construct a page using returned query?
I have loved that encoding. It add alot to security :)

Stefano Mtangoo 455 Senior Poster

This may be a little hard to understand. But instead of:

try:
        n = int(how_many)
        return n
    except:
        print "You can't trick me, that is not integer!"

here's what you should do:

try:
        n = int(how_many)
    except ValueError:
        print "You can't trick me, that is not integer!"

It's just a good habit when checking for invalid types.

Oops! Noted!
Thanks friend :)

Stefano Mtangoo 455 Senior Poster

Here is what wxPython Demo says about it:

Although Microsoft has deprecated the MDI model, wxWindows still supports it. Here are a couple samples of how to use it - one straightforward, the other showing how the MDI interface can be integrated into a SashWindow interface.

My question is, is it really deprecated? Can I use it in my application with ZERO worries?

Stefano Mtangoo 455 Senior Poster

Use IDLE, Notepad++, ulipad, or editor/IDE of your choice.
Using Commandline is poorest idea. Anyway if you still wish to do that, Add Python path to your system path and type on console:
python

There you are!

Stefano Mtangoo 455 Senior Poster

do us a favor and mark it solved :)

Stefano Mtangoo 455 Senior Poster

Hi All,
I have register/ Authentication form codes given away by Keith29 (If not mistaken your good name). So what I need here ia the whole Idea of secure register/Authentication so that I will be able to make mine. I would like also to integrate my login system with that of PHBB3. I have read some posts and I need to get the basics (Especially on security side) then I will jump on specifically PHPBB3 integration.

Sorry for many words but hope you guys understands what I mean

Many thanks!

Stefano Mtangoo 455 Senior Poster

Can you give me an example?

Stefano Mtangoo 455 Senior Poster

Can you give me an example?

Stefano Mtangoo 455 Senior Poster

Hi All,
I have been learning making CMS and you guys have been helpful.
I can now post, and view the posts. I need to edit/delete articles.
I have read somewhere that you can make a link that appends an id of the article and you can retrieve it via $_GET. I cannot understand it and need help. Also another question, is that method safe? I read another place that GET method isn't secure!
Thanks!

Here is the code: view.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  <title>Articles</title>
  <link type="text/css" rel="stylesheet" media="all" href="/site/site.css" />
</head>
<body>
<?php
	require('/includes/inc.database.php');
?>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
    <tr>
      <td colspan="3" rowspan="1" id="header">
	  
	  </td>
    </tr>
	
    <tr>
        <td style = "width:230px;">
		
		</td>
		
		<td id="contents">
			<?php
				$db = new Connectdb();
				$conn = $db->connect();
				$article = $db->retrievedata($conn, 'articles');
				//loop in the result
				while ($row = mysql_fetch_object($article)) {
				echo ("<center><h2>$row->heading</center></h2>");
				echo("<br />");
				echo("<p style='color:red;'><b style='color:black;'>Posted by </b> $row->creator  <br /> $row->update_date </p>");
				echo("<br />");
				echo ($row->contents);
				echo("<br />");
				echo ("<p style='color:red;'><b style='color:black;'>Posted under: </b><em>$row->description</em> </p>");
				//add link to edit or delete article
				$pagetitle = "Testing the Change";
				//make a break line and space for next article
				echo '<br />';
				echo '<hr style ="color:red;" />';
				echo '<br />';
				}
				
			?>
	  </td>  	  
	  
	  
      <td style = "width:230px;">
	  
	  </td>
	  
    </tr>
	
    <tr>
      <td colspan="3" rowspan="1" id="footer">
	  <?php include("/includes/inc.footer.php"); ?>
	  </td>
    </tr>
</table>
<br>
</body>
</html>
Stefano Mtangoo 455 Senior Poster

Have you tried andrea gavana's gui2exe? It have many options that comes from py2exe. It have also other 'packers' options.
Check if it can solve your problem

www.code.google.com/p/gui2exe/

Stefano Mtangoo 455 Senior Poster

That's where sockets comes in MHO.
You will use to send data to the server and then there will be a thread opened to server to save each query. So theoretically this is what I would do :
1. Connect to the server via sockets and server's mysql-python module
2. Use that connection to send queries
3. Close database connection and end socket session

Just my 2cents

Stefano Mtangoo 455 Senior Poster

Thanks,
let me work on that and will feedback on what I have gone so far!

Stefano Mtangoo 455 Senior Poster

try learning by dividing the issues at hand using functions:
1.Function that Gets numbers entered by the userand first ask the user how many numbers there are.
2. Find average should always be a float, even if the user inputs are all

#function to get numbers and store them --> store is only for practice
def getvalues():
    how_many = raw_input("How Many Numbers are we operating on? \n")
    #Chek if the provided answer is correct
    try:
        n = int(how_many)
        return n
    except:
        print "You can't trick me, that is not integer!"
        getvalues()

def storevalues(n):
    s = []
    for i in range(0, n):
        ret = raw_input("Enter %dth number: \n" %(i+1, ))
        s.append(ret)
    return s

def calc():
    n_times = getvalues()
    t_list = storevalues(n_times)
    #our calculation container
    cont = 0
    for i in t_list:
        cont+=float(i)
    result = float(cont)/n_times
    print "The result to two decimal places is %.2f" %(result, )

calc()
Stefano Mtangoo 455 Senior Poster

try learning by dividing the issues at hand using functions:
1.Function that Gets numbers entered by the userand first ask the user how many numbers there are.
2. Find average should always be a float, even if the user inputs are all

#function to get numbers and store them --> store is only for practice
def getvalues():
    how_many = raw_input("How Many Numbers are we operating on? \n")
    #Chek if the provided answer is correct
    try:
        n = int(how_many)
        return n
    except:
        print "You can't trick me, that is not integer!"
        getvalues()

def storevalues(n):
    s = []
    for i in range(0, n):
        ret = raw_input("Enter %dth number: \n" %(i+1, ))
        s.append(ret)
    return s

def calc():
    n_times = getvalues()
    t_list = storevalues(n_times)
    #our calculation container
    cont = 0
    for i in t_list:
        cont+=float(i)
    result = float(cont)/n_times
    print "The result to two decimal places is %.2f" %(result, )

calc()
Stefano Mtangoo 455 Senior Poster

Hi.

I figures out the Oracle issue now just ran into another issue. I was my results from my sql to display in the static text box (read only) but I want to add a header and then followed by the result shown line by line without the format of a list. any ideas or pointers?

class MainWindow(wx.Panel):
    def __init__(self,parent,id):
        wx.Panel.__init__(self,parent,id)

        self.background = wx.Panel(self)
        
        header = ['Date','Perf']

        
        lblHeader = wx.StaticText(self,-1,label='AHL PERF CALCULATION',pos=(100,10),style=wx.ALIGN_CENTER)
        font = wx.Font(15,wx.BOLD,wx.NORMAL,wx.ITALIC)
        lblHeader.SetFont(font)
        
        
        lblComboBox = wx.StaticText(self,-1,label='Fund_id:',pos=(5,65))
        self.Fund_id = wx.ComboBox(self, -1, pos=(120,60), size=(100,25), choices=['fund1','fund2'], style=wx.CB_DROPDOWN)
        lblStartDate = wx.StaticText(self, -1, label='Start_date:', pos=(5,105))

        self.StartDate = wx.TextCtrl(self, -1, pos=(120,100), size=(100,25))
        lblEndDate = wx.StaticText(self,-1,label='End_date:',pos=(5,145))

        self.EndDate=wx.TextCtrl(self,-1,pos=(120,140),size=(100,25))

        self.myButton = wx.Button(self, label='Execute', pos=(50,200), size=(100,25))

        self.Bind(wx.EVT_BUTTON,self.OnExecute,id= self.myButton.GetId())
        Exit = wx.Button(self, label='Exit', pos=(200,200), size=(100,25))

        self.Bind(wx.EVT_BUTTON, self.OnExit, id=Exit.GetId())

        self.transferArea = wx.TextCtrl(self, pos=(20,250),size= (1000,500),style = wx.TE_READONLY | wx.TE_MULTILINE)

            
    def OnExecute(self,event):
       # try:
        connection = cx_Oracle.connect('/@resd1')
        cursor = connection.cursor()
        fund_id = self.Fund_id.GetValue()
        print fund_id
        start_date = self.StartDate.GetValue()
        print start_date
        end_date = self.EndDate.GetValue()
        print end_date
        sql="""Select * from table where fund_id = '%s' and datetime >= to_date('%s','DD/MM/YYYY') and datetime <= to_date('%s','DD/MM/YYYY')""" %(str(fund_id),str(start_date),str(end_date))
        print sql
        cursor.execute(sql)
        result = []
        for line in cursor:
            line = [str(entry) for entry in line]
            result.append(line)
            print line

#THIS IS WHERE I AM GOING WRONG!
        for line in result:
            header = ['Date','Perf']
            self.transferArea.SetValue(str(header)+"\n")
            self.transferArea.SetValue(str(line))

    def OnExit(self,event):
        self.Destroy()  # Close the frame.

app = wx.App()
frame = wx.Frame(None,-1,"AHL PNL")
MainWindow(frame,-1)
frame.Show(1)
app.MainLoop(

Is is it MUST that you should use Oracle? If not try other databases

Stefano Mtangoo 455 Senior Poster

As jlm699 said, Postgresql is good but isn't the only one.
You can go with mysql plus mysql-python.
I have read yahoo! and many other big companies uses mysql(not sure if it is with Python or PHP) so I know it must be multiuser!

Stefano Mtangoo 455 Senior Poster

No dude(dudess?)
store the 10 digit timestamp in the database
convert to text on output
Mysql does not care what it looks like and it is faster smaller and simpler for mysql to process the numeric to search for records between 1 January and 1 March
the returned $time function is much larger than 10bytes
that function would be better in the script used output data to be human readable in reports
Store $ptime
$ptime 1234568888
$stime Monday 13 Feb 2009 10:55am

So what is your suggestion? I mean can you show me with a code example? That will be of much help.
Thanks for reply also!

Stefano Mtangoo 455 Senior Poster

so in such a code as mine how do I do redirect after operation like inserting tables successful? Any header tutorial?

Stefano Mtangoo 455 Senior Poster

I have been thinking if this is only possible to very very very advanced wxPyees. I have tried and tried to understand this but with no success. I have seen Mike saying the same in wxpy listing and many more. I have started this to hear your experience with printing framework for wxWidgets/wxPython.

To me it is mystery that needs to be solved :-O

Stefano Mtangoo 455 Senior Poster

Hi, its me again!
I have faced this error trying to redirect from one page.
Here is the error:

Warning: Cannot modify header information - headers already sent by (output started at I:\xampplite\htdocs\site\insert.php:3) in I:\xampplite\htdocs\site\insert.php on line 28
Illegal action or other errors!

here is insert.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<?php 
//$_SESSION["name"] = "Test Admin";
$content = $_POST["content"];
//prepare data
//array should have description , heading , contents, creator 
//$array_values function name insertdata
$values['description'] = $_POST["content"];
$values['heading'] = $_POST["heading"];
$values['contents'] = $_POST["contents"];
//this will include currently loggen in user
$values['creator'] = "Test Admin" ;//$_SESSION["name"];

//database call
require("/includes/inc.database.php");
$db = new Connectdb();
$conn = $db->connect();
$data = $db->retrievedata($conn, 'articles');

if ($db->insertdata($conn, $values)){
	echo("Insert Succesful!");
	header('Location:/site/view.php');
	die("Illegal action or other errors!");
	}
else{
	echo("Failed to write an article");
	header('Location:/site/editor.php');
	die("Illegal action or other errors!");
}

?>
</body>
</html>
Stefano Mtangoo 455 Senior Poster

I solved it with gmdate()

function getnow(){
	//mysql date format -- 'YYYY-MM-DD HH:MM:SS'
	// Create the UNIX Timestamp, using the current system time
	$ptime = time();
	// Convert that UNIX Timestamp into a string (GMT), safe for MySql -- GMT +3
	$toffset = +3.00;
	$stime = gmdate("Y-m-d H:i:s", $ptime+$toffset * 3600);
	return $stime ;
	}
Stefano Mtangoo 455 Senior Poster
public function connect($host = self::HOST, $user = self::USER, $passwd = self::PASS, $db = self::DATABASE)

gives no error :)

Stefano Mtangoo 455 Senior Poster

I found removing default value in the line

public function connect($host = $this->HOST, $user = $this->USER = "root", $passwd = $this->PASS, $db = $this->DATABASE ){

works. I'm trying to use constants

Stefano Mtangoo 455 Senior Poster

For Complete Date & time Statement in PHP with MySQL Please Go to:
http://in2.php.net/manual/en/function.date.php

The above will give u all your problem solution.
Thank You..

Thanks, I'll check!

Stefano Mtangoo 455 Senior Poster

try this:
http://www.daniweb.com/search.php?x=31&y=30&q=import+sqlite3

and specifically this:
http://www.daniweb.com/forums/thread209685.html

It's for sqlite but will mostly work with any SQL.
Check python-mysql module and start coding :)
Have any problem? Post it here!!

Stefano Mtangoo 455 Senior Poster

Dont format the date time in the database
text formatted dates are for humans to read, sql is not human does not need any of that and it makes the processing slower
sql Date, php date, unix timestamp, are all a single 10byte numeric that stores complete date and time
formatting is done for human readability on output
example <?php echo date('DMY h:m',$timestamp} ?> selecting a timestamp renage from num1 to num2 is much faster - less processing than searching text dates for dates between x and 1
sql now() will input the date and time of the update as the update is processing
php date() is now

1253454900 (10bytes)
or
September 20 2009, 1:55pm (25bytes)

not much on 1 row, very much on a million rows

select * from table where date > 1234567890 and date < 1234568890
is much faster than precessing text dates
processing script languages have strtotime() (or an identical function) built in, you dont even have to do any text to time conversions on range select fields

text date time: not good

Thanks for explanations. Can you please give example of how to use it?

Stefano Mtangoo 455 Senior Poster

Any suggestion on reformatting the above code?
Is it good enough to do the job?
Thanks for the answer!

Stefano Mtangoo 455 Senior Poster

Ok all I want is having class that will handle all database issues. All I'm trying to accomplish is making very simple CMS for my little website (developing in WAMP). I have set already Editor, and now I want to setup database functions to do the inserting of articles, editing and deleting them.
you can help me get it right if I'm doing it wrongly or suggest better if not best method of doing it.

thanks!

Stefano Mtangoo 455 Senior Poster

modified but I still get error!
I cannot understand (do I need to rest?)
Uuuh!

Stefano Mtangoo 455 Senior Poster

do you mean this?

constant var = 5;

I have seen it in manual but not used it!

Stefano Mtangoo 455 Senior Poster

I need to format PHP to use with one of my date field (DATETIME).
I want to get current time and format it. I have checked some googled articles but I cannot get far.
Please help me!

Stefano Mtangoo 455 Senior Poster

Help me inspect this code.
I cannot see error by myself.
here are the codes for inc.database.php

I'm learning OOP with PHP (I extensively using it with python but I'm noob to PHPiing)

<?php
class Connectdb{
private	$DATABASE = "site_contents";
private	$HOST = "localhost";
private	$USER = "root";
private	$PASS = "jesus";

public function __construct(){}

public function connect($host = $HOST, $user = $USER = "root", $passwd = $PASS, $db = $DATABASE ){
$conn = mysql_connect($host, $user, $passwd) or die("Cannot Connect to the database $db");
mysql_select_db($db, $conn) or die("Unable to select database");
return $conn;
}

public function insertdata($conn, $array_values){
//array should have id, update_date , description , heading , contents, creator 
if (isset(_POST["save"])){
$query = 'INSERT INTO articles(id, date_date , description , heading , contents, creator) VALUES($array_values['id'], $array_values['update_date'], $array_values['description'], $array_values['heading'], $array_values['contents'], $array_values['creator'])';
if(mysql_query($query){
echo "Successful Inserted!";
header('Location:/site/view.php');
die("Illegal action, contact admin!");
}
}
}

public function retrievedata($conn, $table){
$query = 'SELECT * FROM $table';
$result = mysql_query($query);
$row = mysql_fetch_object($result);
return $row;

}

}

?>
Stefano Mtangoo 455 Senior Poster

Why not use 2.5. There is binary version of it.
Just search this forum. I posted it somewhere here :)

Stefano Mtangoo 455 Senior Poster

sorry for the lack of info. it will reside on the back end. I'd like to keep my database updated with certain information queried from other 3rd party API's and i figured i could write a python script to accomplish this as well as other maintenance tasks. so the user would have nothing to do with it. it would just do all of the automated tasks i would program it to do.

hope that helps

I will use python-mysql and then run the script automatically using CRON or CRON like tool depending on platform

Stefano Mtangoo 455 Senior Poster

Thanks alot.
I will incorporate your Ideas. They are great!
Thanks

Stefano Mtangoo 455 Senior Poster

Don't get me wrong, I don't ignore the power behind CMSes.
I want to make a Database driven contents. Here is the approach I want to take, correct me/Add opinion as you it!

1. Integrate TinyMCE editor for wariting contents (WYSIWYG)
2. Have database with table contents and three columns (ID, heading, contents)
3. Feed heading and contents to table
4. Display contents by querying the DB for data using a php script

Is it right approach?
Any suggestion/modifications?

Thanks :)

Stefano Mtangoo 455 Senior Poster

I haven't tested but Matlab is said to be best pythonic graphing of complex plots. Not sure because haven't used it. There are examples in matlab homepage. Test them and see if it suits you!

Stefano Mtangoo 455 Senior Poster

how does that script look like?
post source code, at least suspected erroneous part.

Stefano Mtangoo 455 Senior Poster

where will python reside? In server or client machine
Can you explain more? I have tried to understand what you want to do but I haven't got you well.

You can take a look at mysql module
http://mysql-python.sourceforge.net/