27, May 2012

cant get it to work - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: cant get it to work
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: cant get it to work  (Read 1105 times)
Just another rainy day
*
Posts: 1
10 credits
Members referred : 0


« on: Jun 23, 2010, 09:54:05 am »

Here's what I did in my access class. I added it at the end.
Code:
function getID()
{
return $this->userData[$this->tbFields['userID']];
}
}

In my php file I added this:
Code:
$user = new flexibleAccess();
$displayID = $user->getID();

I can echo $displayID, but I can't add it to the db. It won't initialize, but if I initialize it to zero or something, it works fine. I want to be able to insert the userid in the table and not a hard coded number like zero.

Here's my php file (I added my access.class.php to config.php):
Code:
<?php
include_once ("config.php");
include_once (
"function-library.php");
function 
log_data($data)
{
$ourFileName "logs/" date("Y-m-d") . ".txt";
$ourFileHandle fopen($ourFileName'a') or die("can't open file");
fwrite($ourFileHandledate("d/m/Y H:i:s") . ": " $data "\n");
fclose($ourFileHandle);
}
log_data("Started import of " $_FILES['Filedata']['name']);
$userip $_SERVER['REMOTE_ADDR'];
log_data("User IP is " $userip);
$filesize $_FILES['Filedata']['size'];
$tmpfile $_FILES['Filedata']['tmp_name'];
$filename $_FILES['Filedata']['name'];
$contenttype $_FILES['Filedata']['type'];
$extension pathinfo($_FILES['Filedata']['name']);
$extension strtolower($extension[extension]);

$user = new flexibleAccess();
$displayID $user->getID();

if (
$filesize == 0$error .= "Please specify an image file to upload.<br>";
else
{
$valid_ext_types = array('jpeg''jpg''gif''png');
if (!in_array($extension$valid_ext_types))
{
$error .= "File type does not appear to be a supported image (" $extension "). Please try another format.<br>";
}
if ($filesize $max_upload_size$error .= "Uploaded file is greater than the maximum filesize. (" $max_upload_display_size ")<br>";
}
if (
strlen($error) == 0)
{
$uploaddir 'storage/originals/';
$newfilename randomfilename() . "." $extension;
$uploadfile $uploaddir $newfilename;
if (!move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadfile))
{
$error .= "Could not move file into storage, please try again later.";
}
else
{
// add to db
$userip $_SERVER['REMOTE_ADDR'];
list($originalwidth$originalheight$type$attr) = getimagesize($uploadfile);
// check for refreshes
$check_image "SELECT id FROM images WHERE mimetype = '" preparedata($contenttype) . "' AND originalfilename = '" preparedata($filename) . "' AND filesize = '" preparedata($filesize) . "' AND description='" preparedata($imgdesc) . "' AND originalip='" preparedata($userip) . "' AND originalwidth='" $originalwidth "' AND originalheight='" $originalheight "' LIMIT 1";
$do_check_image = @mysql_query($check_image);
if ($do_check_image)
{
if (mysql_numrows($do_check_image) > 0)
{
$error .= "It looks like you've already added this image, please go back and upload a different one.";
unlink($uploadfile);
}
}
if (strlen($error) > 0log_data("ERROR: " $error);
else
{
$tracker randomfilename();
$insert_image "INSERT INTO images (dateadded, mimetype, originalfilename, filename, filesize, description, originalip, originalwidth, originalheight, lastaccessed, tracker, mutracker, owner) VALUES (NOW(), '" preparedata($contenttype) . "', '" preparedata($filename) . "', '" preparedata($newfilename) . "', '" preparedata($filesize) . "', '', '" preparedata($userip) . "', '" $originalwidth "', '" $originalheight "', NOW(), '" preparedata($tracker) . "', '" preparedata($mutracker) . "', '".$displayID."'";
$do_insert_image = @mysql_query($insert_image);
$item_id mysql_insert_id();
if ($do_insert_image)
{
log_data("SUCCESS: Image successfully uploaded. Ref: " $item_id);
}
}
}
}
else 
 log_data("ERROR: " $error);
log_data("Finished import process for " $_FILES['Filedata']['name'] . "\n\r");
?>

Any ideas?
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=10150
Tags : php Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: cant get it to work
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 08:59:32 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 62.814
Total Topics: 11.028
Total Members: 21.451
Tutorials : 58
Resources : 929
Designs : 395
Latest Member: sobbin

92 Guests, 2 Users online :

12 users online today:




Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.