Jump to content

Ivan Ivković

Members
  • Posts

    139
  • Joined

  • Last visited

    Never

Everything posted by Ivan Ivković

  1. Since I know nothing about your code, I'll improvise. 1. In your login, you should have a user_id. ($_SESSION['user_id']) 2. In the database, the uploads table should have columns uploader_id. When you upload the file, the query should contain: $query = "INSERT INTO uploads SET uploaded_file = $file, uploader_id = $_SESSION['user_id'] "; 3. When printing out the upload, the query should have this: $query = "SELECT uploaded_file_id, uploaded_file, username FROM uploads JOIN users ON uploads.uploader_id=users.user_id"; And then when you print out username, you'll get your user who uploaded the file.
  2. Maybe you're using position: relative; left: (number)px; ? I know that happened to me when I used position: relative while looping divs. If you are, then try not to position those divs by relative or absolute position, but by static. If that was not the problem, then I don't know what the problem is. Maybe post the full code?
  3. It is (I suppose). I'll copy the objects in the content file, too when I get to my PC.
  4. // Form fetching if(isset($_POST['option'])){ $selected_option = $_POST['option']; // Your selected option successfully posted. Now do anything with it. } // Options listout with onselect - post option <?php mysql_connect("localhost","******","*****"); mysql_select_db("checkmyw_database") or die("Unable to select database"); $result = mysql_query("SELECT DISTINCT user_id username FROM members"); // USER ID MUST BE FETCHED AND SELECTED ?> <form action="/new/newrotastaffprocess.php" method="post"> <div style="position:absolute; top:400px; left:400px;"> <?php echo '<select name=\'user\' onchange=\'this.form.submit()\'><option selected>Select a User</option>'; // onchange=\'this.form.submit()\' is what submits the form. echo 'Create New...</option>'; while ($row = mysql_fetch_array($result)){ $username = $row["username"]; echo "<OPTION value=\"$_POST['user_id']\">{$_POST['username']}</OPTION>"; } echo '</select>'; ?> </div> </form> // YOU DIDN'T CLOSE THIS One more thing, I suggest you start using mysqli function for database. And more of these ''. "" check for variables, '' check only for text so it's faster.
  5. And if you really have to seperate variables somehow, don't use new line or blank space. Use '/' or '_'.
  6. Like thorpe said, you shouldn't be storing multiple variables as one row. $data = explode('\n', $fetch['description']);
  7. dzelenika : Fatal error : Call to a member function query() on a non-object in sportvillecms\classes\page.php on line 152 gizmola: It's not my class that has the query() method, but the object $db; that I'm trying to pass by using extend feature. REMINDER: $result = $this -> db -> query($query); What You are saying would be: $result = $this -> query($query); // and that is not the case. Thanks you for answering! Hope you help me further in time.
  8. It seems that a class can't inherit an object as attribute? I'm trying to make my UpperNavigation class access the $this -> db attribute which is a mysqli connection. Is this possible? If not, how do I manage my connection in other classes? class Connection{ public $state = false; public $db; public $db_table_names; function __construct($name){ include('dbconfig.php'); $this -> db = new mysqli($dbconfig[$name]['server'], $dbconfig[$name]['username'], $dbconfig[$name]['password'], $dbconfig[$name]['database']); $this -> state = true; $this -> db_table_names = $db_table_names; $this -> db -> query("SET NAMES 'UTF8'"); } function close(){ if($this -> state == true){ $this -> state = false; $this -> db -> close(); unset($this -> db); } } } This is my attempt of accessing Connection::$db connection. class UpperNavigation extends Connection{ public $all_parents_sorted; public function printUpperNavigation(){ echo '<a href=\''.$this -> current_page.'\'>'.$this -> title . '</a>'; } public function printSearchBar(){ echo '<input type=\'text\' value=\'Search by name...\' onfocus="if(this.value == \'Search by name...\'){this.value = \'\';}" onblur="if(this.value == \'\'){this.value = \'Search by name...\';}"/>'; } public function fetchAllParents($sp_id){ $latest_id = $sp_id; if(isset($this -> db)){ echo 'yes'; }else{ echo 'no'; } $query = 'SELECT default_name, type, sp_id FROM ' . $this -> db_table_names['sport'] . ' WHERE sp_id = "' . $sp_id . '"'; $result = $this -> db -> query($query); // THIS IS THE PROBLEM } }
  9. I made a CMS for TONS of complicated data to insert. I made multiple text boxes for each unit of data (i.e. 10 textboxes for quick-insert of 10 employees). I have text files with tons of data to post to the database. I want to copy 10 units, paste them into the first textbox, and I want it to be pasted to other 9 textboxes. Is that possible? EXAMPLE : (copied text): Name Surname Name Surname Name Surname Name Surname Name Surname Name Surname Name Surname Name Surname Name Surname Name Surname (pasted): 1.textbox > Name Surname 2.textbox > Name Surname 3.textbox > Name Surname 4.textbox > Name Surname 5.textbox > Name Surname 6.textbox > Name Surname 7.textbox > Name Surname 8.textbox > Name Surname 9.textbox > Name Surname 10.textbox > Name Surname
  10. The problem in mikesta's possible solution is that if someone would type 'logout.php' in the browser, he would be logged in. So it's good to create a link with a encrypted $_GET variable like this: LOGOUT BUTTON ON THE PAGE: $getvalue = 'ok'; $get = urlencode($getvalue); echo "<a href='logout.php?logout={$get}'>Logout</a>"; ONCLICK: (logout.php) if(isset($_GET['logout'])){ $get = urldecode($_GET['logout']); if($get == 'ok'){ $session->logout(); }else{ header('index.php'); } } P.S. I think there is no redirect_to() function in PHP. Use header('Location: login.php');
  11. If you're building an international site, NOW() could be replaced with nicely formatted gmtdate(). But let's leave it with that. It's good to make {} braces fir variables in your queries too. $username = mysql_real_escape_string($_POST['username']); $sql2 = "INSERT INTO mailbox values ('','locked','','{$username}','',NOW(),'','locked','')";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.