wandie 0 Light Poster

All i need is help to to just move the pic to the webserver. For some reason the image doesnt want to be moved:icon_cry:

wandie 0 Light Poster

I have a created a page to upload images. Can someone please help me. When when I click on browse I would like the picture to go on the server and not change the image name. just to upload the image as it is. please help

<?php

include('../includes/cms.config.php');

require_once('login.php');

## Get MySql DB Settings
session_start();
$dbconn = mysql_connect($server,$user,$password) or die('Cannot connect');
mysql_select_db($db) or die('Cannot select db');

if ((isset($_GET['cat']) or isset($_POST['cat']))){
if (($_GET['cat']=="Add Product")or($_POST['cat']=="Add Product")){
if (isset($_POST['product'])){

$pname = $_POST['product'];
$pcode = $_POST['productcode'];
//$pimage = $_POST['image'];
$pcat = $_POST['category'];
$pdesc = $_POST['fulldesc'];
$prank = $_POST['rank'];
$pprice = $_POST['price'];
$today = date("Y/m/d");

        if($_FILES['pictureFile']['tmp_name'] == "none"){
            echo "<b>File did not successfully upload. Check the
            file size. File must be less than 500K.<br>";
            include("product.php");
            exit();
        }
/*
        //check to see if the file is an image
         if(!ereg("image",$_FILES['pictureFile']['type'])){
            echo "<b>File is not a picture. Please try another
            file.</b><br>";
            include("product.php");
            exit();
        }
        else */
        {   
                        [B]//$destination = './images'."/".$_FILES['pictureFile']['name'];
                       $destination = "./images/".$_FILES['pictureFile']['name'];
          $temp_file = $_FILES['pictureFile']['tmp_name'];
                     @move_uploaded_file($temp_file,$destination);[/B]

            //get the values
            $pimage = $_FILES['pictureFile']['name'];

            $query = "INSERT INTO tblproduct (`ProductCode`,`Date`,`ProductName`, `Image`, `Category`, `ProductDescription`, `Rank`, `Price`) VALUES ('$pcode','$today','$pname','$pimage','$pcat','$pdesc','$prank','$pprice')";
wandie 0 Light Poster

Can someone please help me I have made an example, of an cookies I have added a value 45 but i have created another page that displays. This prob is when i run the code that has the value 45 its suppose to give me a blank page byut i get this error on my browser

"Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\lesson\cookies\cookies.php:6) in C:\xampp\htdocs\lesson\cookies\cookies.php on line 11"

this is the code i put the cookie its suppose to just give a blank page but the value is stored in the cookie

<?php
	setcookie('test',45, time()+(60*60*24+7));
?>
wandie 0 Light Poster

Mysql I am trying to display the info just like the one on the url i sent "http://www.devarticles.com/c/a/MySQL/Building-A-Persistent-Shopping-Cart-With-PHP-and-MySQL/2/"

the results should be at the bottom

wandie 0 Light Poster

If that is all the code from the page it is because you forgot the closing curley brace } for the while loop

Thanks would anyone know where i can get info on how to display information from a database or retrieve info for my items and display them on the page

wandie 0 Light Poster

Could some please help me. I am following a tutorial from "http://www.devarticles.com/c/a/MySQL/Building-A-Persistent-Shopping-Cart-With-PHP-and-MySQL/2/"

I keep getting a "
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\cart1\products.php on line 59"

My db connection is fine but I am trying bring a result from the diagram shown in the url. Please help. This is what I have put in my code from the site the products page.

<?php

// This page will list all of the items
// from the items table. Each item will have
// a link to add it to the cart

include("db.php");

// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * from items order by itemName asc");

?>
<?php
while($row = mysql_fetch_array($result))
{
?>
<html>
<head>
<title>Products</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table>
<tr>
<td width="30%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemName"]; ?>
</font>
</td>
    <td width="10%" height="25"> <font face="verdana" size="1" color="black"> <?php echo $row["itemPrice"]; ?> 
      </font> </td>
<td width="50%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemDesc"]; ?>
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
<a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1">Add Item</a>
</font>
</td>
</tr>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="red" NOSHADE>
</td>
</tr>
<tr>
<td width="100%" colspan="4">
<font face="verdana" size="1" color="black">
<a href="cart.php">Your Shopping Cart &gt;&gt;</a>
</font>
</td>
</tr>
</table>
</body>
</html>
wandie 0 Light Poster

Please help I have Norton Internet Security 2008 I want to install it on a client pc under a win2000 domain. I installed everything but the network connection went down.The win xp client pc uses a default gateway to access the internet. Is there a way , where it wont block the current settings to access the internet or the network.
Please help is there an option which i can disable?

please help :(

wandie 0 Light Poster

Thank you for the code it works. Well it displays the window but Its not getting the data from the getdata.py here is the code.For the getdata

import MySQLdb
 
class Eb_db:
    def __init__(self):
        try:
            connection = MySQLdb.connect(host="localhost",
            user="root", passwd="scott", db="phonebook" )
            cursor = connection.cursor()
            cursor.execute( "SELECT * FROM details " )
        except MySQLdb.OperationalError, message:
            errorMessage = "Error %d:\n%s" % (message[ 0 ], message[ 1 ] )
            return
        else:
            self.data = cursor.fetchall() 
            self.fields = cursor.description 
            cursor.close() 
            connection.close()
wandie 0 Light Poster

I got this error when i was running a tuturial on how to view data using a grid in wx. I downloaded the modules for wx. I wandering if anyone can help me. this is the error i got

Traceback (most recent call last):
  File "C:\Update\data.py", line 7, in <module>
    class MyFrame(wx.Frame):
  File "C:\Update\data.py", line 27, in MyFrame
    self.grid_1.SetColLabelValue(index, item[0])
NameError: name 'self' is not defined

This is the code i put in.

import wx   
import wx.grid   
import getdata
db = getdata.Eb_db()
class MyFrame(wx.Frame):
 
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.grid_1 = wx.grid.Grid(self, -1, size=(1, 1))
        self.__do_layout()
        # end wxGlade   
    def __set_properties(self):   
       # begin wxGlade: MyFrame.__set_properties   
       self.SetTitle("frame_1")   
       self.SetSize((400, 400))   
      # end wxGlade
       self.grid_1.CreateGrid(len(db.data),len(db.fields))
 
    for item in db.fields:
        index = 0 
        self.grid_1.SetColLabelValue(index, item[0])
        index += 1
    for row in range(len(db.data)):
        for col in range(len(db.data[row])):
            values = db.data[row][col]
            self.grid_1.SetCellValue(row,col,str(values))
    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 =wx.BoxSizer(wx.VERTICAL)
        sizer_1.Add(self.grid_1, 1, wx.EXPAND, 0)
        self.SetAutoLayout(True)
        self.SetSizer(sizer_1)
        self.Layout()
        # end wxGlade
        # end of class MyFrame
if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()

got the example on this site: http://www.serpia.org/mysql. If you know any other tutorials i can try to view data from mysql database.

wandie 0 Light Poster

could please help me on what am i doing wrong

wandie 0 Light Poster

I used to this code for a splash screen but doesn't run. Please could someone assist. Or help with a link I can check Tkinter splash screens.

from Tkinter import *
try:
     from PIL import Image, ImageTk
except ImportError:
     import Image, ImageTk

class SplashScreen(Toplevel):
     def __init__(self, master, image=None, timeout=1000):
         """(master, image, timeout=1000) -> create a splash screen
         from specified image file.  Keep splashscreen up for timeout
         milliseconds"""
         Toplevel.__init__(self, master, relief=RAISED, borderwidth=5)
         self.main = master
         if self.main.master != None: # Why ?
             self.main.master.withdraw()
         self.main.withdraw()
         self.overrideredirect(1)
         im = Image.open(image)
         self.image = ImageTk.PhotoImage(im)
         self.after_idle(self.centerOnScreen)

         self.update()
         self.after(timeout, self.destroy)

     def centerOnScreen(self):
         self.update_idletasks()
         width, height = self.width, self.height = \
                         self.image.width(), self.image.height()

         xmax = self.winfo_screenwidth()
         ymax = self.winfo_screenheight()

         x0 = self.x0 = (xmax - self.winfo_reqwidth()) / 2 - width/2
         y0 = self.y0 = (ymax - self.winfo_reqheight()) / 2 - height/2
         self.geometry("+%d+%d" % (x0, y0))
         self.createWidgets()

     def createWidgets(self):
    # Need to fill in here
         self.canvas = Canvas(self, height=self.width, width=self.height)
         self.canvas.create_image(0,0, anchor=NW, image=self.image)
         self.canvas.pack()

     def destroy(self):
         self.main.update()
         self.main.deiconify()
         self.withdraw()

if __name__ == "__main__":
     import os
     tk = Tk()
     l = Label(tk, text="Phone Book")
     l.pack()
     
     n = Label(tk,text="Name")
     n.pack()
     E1=Entry(tk,width=40)
     E1.grid(row=1,column=0)
     E1.pack()

     b = Button(tk,width=40)
     b.grid(row=1,column=0)
     

     s = Label(tk,text="Surname")
     E2=Entry(tk,width=40)
     E2.grid(row=1,column=0)
     E2.pack()

     nr = Label(tk,text="Number")
     E3=Entry(tk,width=40)
     E3.grid(row=1,column=0)
     E3.pack()

     

     assert os.path.exists("python.jpg")
     s = SplashScreen(tk, timeout=5000, image="python.jpg")
     mainloop()
wandie 0 Light Poster

Soemthing like that?

s = "c:/hello/scot"
if s.endswith("scot"):
    s = s.replace("scot", "bob")
 
print s  # c:/hello/bob

Sorry exactly.

The program first asks you select a directory.
Then the listbox selection adds another directory.
So in other words first I select a directory with the use of:

tkFileDialog.askdirectory()

first step:
"c:/cars" the use of tkFileDialog
then its stored in the a entry box.
so now the entry box contains:
c:/cars
second step:
I select "/benz" that is the text in the listbox:
Which contains "/ferrai";"/benz";"/opel"
then the entry box contains the following
c:/cars/benz

Problem is when I select another value in the list box from benz to ferrai. It Deletes the entire path.Whenever i would like to change:benz to ferrai or opel all from the list box. I would like it to update /benz part.through the list box values

wandie 0 Light Poster

Thanks for the code. But everytime I select a value its in the textbox and when I select another I want it to refresh the current position.for example:
I select scot in the list box

c:/hello/scot

then i select another in the list box

c:/hello/bob

I would want it to change just /scot to /bob

Please Help

wandie 0 Light Poster

Hmm ... I don't think the problem is there. Could you post more of the code?

Here is more code.

def get_list(event):
    """
    function to read the listbox selection
    and put the result in an entry widget
    """
    # get selected line index
    index = lb.curselection()[0]
    # get the line's text
    seltext = lb.get(index)
    # delete previous text in enter1
    #E1.delete(0,50)
    # now display the selected text
    test=E1.get()
    E1.delete(len(test),len(seltext)) 
    E1.insert(INSERT, seltext)

Note from vegaseat: corrected proper code tags

wandie 0 Light Poster

I was wondering if you could help me out. I have a list box that has seltext and every time i want to select another item in the list it adds on. for example i select "/hello" then it appears as "/hello" but then i select something else it will look like this "/hello/greetings" I would like for it to refresh here is the code.
"c:/file/hello"
I would like it to change the /hello but not the c:/file.

E1.delete(len(test),len(seltext)) 
    E1.insert(INSERT, seltext)
wandie 0 Light Poster

Could someone please help. I would like to sort a multidimensional array. But to sort it out by one key which appears in all array for example.

total=[[serial,'john'],[[serial,'james']]

all the records i have all in arrays they contain a "serial" i would like sort by serial.

I have used

total.sort()

this sorted that names but johns serial is the first and i would like to sort by serial not by name. Please help :S

wandie 0 Light Poster

Thanks for the assistance. here is the final:)

mystr=""
            for x in results:
                mystr2 = ""
                for y in x:
                    mystr2 = mystr2 + str(y)
                mystr = mystr +str(mystr2)+'\n'
 
            final =open('C:/new_file1.txt','w')
            final.writelines(str(mystr))
            final.close()
wandie 0 Light Poster

Thanks for the assistance it works. But when I want to put the print results in a text file it only reads one line. I have tried this code but still gives me inputs one line :| .

for i in results:
      valfinal=' '.join(map(str,i))
       textfile = file('C:/new_file1.txt','wt')
       final =open('C:/new_file1.txt','w')
       final.writelines(str(valfinal))
       final.close()
wandie 0 Light Poster

How do i take results in a mutli dim array and write it to a text file. Each sub array goes on a new line. I am a newbie at this.

[[2934110, 'B1', 'D4', '7C7C7C7C804040404040F140404000'], [2934110, 5, 1, 1, '01', 'Actes Sud '], [2934110, 4, 1, 2,                 '8C00Dubbelganger (motief)'], [2934110, 3, 1, 1, '01', '01', '03', 'Les amants imparfaits', ' : roman'], [2934110, 6, 7, '104', 0], [2934110, 6, 1, 1, '01', '01', '03', 'Domain'], [2934110, 2, 1, 1, '01', 0, 'C4', 'Fleutiaux, Pierrette']]

I would was wondering if I can place every subarry in a text file as below each new line in the text file will contain a sub array:

[2934110, 'B1', 'D4', '7C7C7C7C804040404040F140404000']
[2934110, 5, 1, 1, '01', 'Actes Sud ']
[2934110, 4, 1, 2, '8C00Dubbelganger (motief)']
[2934110, 3, 1, 1, '01', '01', '03', 'Les amants imparfaits', ' : roman']
[2934110, 6, 7, '104', 0], [2934110, 6, 1, 1, '01', '01', '03', 'Domain']
[2934110, 2, 1, 1, '01', 0, 'C4', 'Fleutiaux, Pierrette']

Please help:'(

wandie 0 Light Poster

Thank you so much it works :)

b=str(a)
print b.count("'a'")
wandie 0 Light Poster

:sad: Please could some please help me out here . I have an array. I want to count how my 'a' appear and the a must have its quotes 'a'

[(' ', ' ', [('a', 'Scott'), ('9', 'vth')]), (' ', ' ', [('a', 'Jenny'), ('9', 'vth')])]

Like this one has 'a' = 2

wandie 0 Light Poster

He is my code

def toR(self):
        " Convert to a readable format"
        keys = self.fields.keys()
        keys.sort()
        leader = self.get_MARC()[:24]
        print "leader:", leader
        for key in keys:
            if key == 0:
                # XXX Skip?? What are these??
                pass
            elif key < 10:
                print "00"+str(key)+":", self.fields[key][0]
            else:
                for instance in self.fields[key]:
                    if key < 100:
                        keystr = "0" + str(key)
                    else:
                        keystr = str(key)
                    ind1 = instance[0]
                    ind2 = instance[1]
                    #print keystr
                result=[key]
                
                               
                print result          
                    #+ ": ind1=" + ind1 + ", ind2=" + ind2
                    #for sub in instance[2]:
                     #  print "  " + sub[0] + ":", character(sub[1])
                        
        print

If the key is less than 10 then add 00s all I need is to put this figures into an array. The code is really big but i am working on this area. Its just the final result I would like it in this format

wandie 0 Light Poster

I have a program that displays its results in this manner. I added the results in an array this is what I got.

[20]
[35]
[40]
[84]
[100]
[245]
[260]
[300]
[440]
[521]
[650]

How can I put it in this way i used append but it didnt work and need to calculate how many times a number appears please someone please help me. :sad:

wandie 0 Light Poster

thank you for the code. sorry for the delay.

wandie 0 Light Poster

I have made a list of names and everytime i want to select a value in the listbox it should give me a result in the Entry box can someone please help me.

This is my listbox values

musicfolder = [
  ["CollegeRock/"],
  ['RnB/'],
  ['HipHop/'],
  ['Build/'],
  ['Buy/'],
  ['Techno/'],
  ['Jazz/'],
  ['Classic/']
]

this is the code i used to get the value and to display it in the Entrybox

#get selected line index
index = lb.curselection()[0]
#print index
seltext = lb.get(index)
#get the line's text
seltext = lb.get(index)
#now display the selecred text
E2.insert(0,seltext)

This is the error I recieve

Traceback (most recent call last):
  File "C:\Documents and Settings\stage1\Desktop\List\List.py", line 88, in -toplevel-
    index = lb.curselection()[0]
IndexError: tuple index out of range