The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri May 11, 2012 5:19 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Jun 23, 2010 9:06 pm
Posts: 21
This is pretty advanced stuff, for my joomla knowledge, so I thought i'd post here.

I'm trying to make a php page that uploads a pic making a uploads a picture, while storing the logged in user's id as a foreign key. but I cant get it working. below are a few relevant samples of code....

whatever.sql
Code:
CREATE TABLE project
(
  projectID            INT(11)      AUTO_INCREMENT, 
  projectImage         varchar(25),
  id                int(11),
CONSTRAINT pk_project_projectID PRIMARY KEY(projectID),
CONSTRAINT fk_prime_users_id FOREIGN KEY (id) REFERENCES prime_users (id)
);


whatever.php
Code:
$user =& JFactory::getUser();
$id = $user->id;

$sql = "INSERT INTO `project`(`projectImage`, `id`) VALUES (`$sqlPicEntry`, `$id`)";

im using flexicode module that allows php in a custom html, i can echo out the user's id. so that is successfully stored in the $id variable.
please help if you can!!!


Top
 Profile  
 
PostPosted: Fri May 11, 2012 9:29 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Wed Aug 17, 2005 10:27 pm
Posts: 14709
Location: Kent, England
[Mod note: Moved from General Forum to 2.5 Coding Forum;]


Top
 Profile  
 
PostPosted: Tue May 15, 2012 3:32 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Oct 30, 2008 7:27 pm
Posts: 149
So how is it not working? You didn't include the code where the SQL statement is actually being executed on the database (ie $db->query()) or how it's being outputted and you didn't give us any other information as to what is or isn't happening.


Top
 Profile  
 
PostPosted: Tue May 15, 2012 8:58 am 
Joomla! Ace
Joomla! Ace

Joined: Sat Oct 01, 2011 7:06 pm
Posts: 1260
Don't use the backtics in the VALUES clause.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 



Who is online

Users browsing this forum: biagiopas, n9iels and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group