veedeoo 474 Junior Poster Featured Poster

Hi,

Let me write a demo first then, I will post it here after I tested it a couple of times.. This is the same method I was using, because I was pretty lazy using the ftp. So, all my php files are generated from my website. At least, I can edit my php files without FTP applications..just Internet connection and I am good to go.

Hold on, please... thanks for the PM... :).

veedeoo 474 Junior Poster Featured Poster

Disclaimer! I really don't know how to code in cold fusion. I was never and will probably not learn it. However, besides PHP, I know how to code in C++, C#, C, python, ruby, a little of PERL, and some robotics programming in ROM. I spent most of my time writing and experimenting with OOP PHP for calculator applications ( I have this vision that PHP can be use as Accounting program , and probably will be able to do a better job in a more complex mathematical applications. The reason I have this pretty ambitious vision is that PHP is FREE and can be extend for whatever module we want to add into it.). The language is just too easy for anyone to replicate any applications.

So pretty much, what I am going to tell you here is a one sided point of views, which is not fair for the cold fusion community. I have no intensions of pursuading anyone, NOR claiming that PHP is an ultimate holy grail in web programming.

Learn PHP, because it is the commonly use language in developement. Web developers has been pretty sucessful using php in cms, forum, shopping cart system, video sharing websites, blog e.g. wordpress. There are many stable frameworks developed for PHP e.g. cake, zend, codeIgniter, and many others. There are many extensible templating systems solely intended for the use of PHP developer.

PHP can also carry out an exec, or shell exec right from the script itself. PHP has …

veedeoo 474 Junior Poster Featured Poster

the query can be something like this.

SET product_InInventory = CountBeforeThePurchase - 'ItemPurchasedByYourClient'

Then you send another query to get the updated count.. Say, you only have 10 items remaining, and your client type in 11.. On your controller file, you should alert the client that they cannot select more than 10.

Another option is to pre-populate your select menu for quantity.. for example

 $available = 11; 
 ## the integer 11 should be from your database.
 $option = array();
 for($qA = 1; $qA <= $available; $qA++){
 $option[] = $qA;

 $smartyOption[] = $option;

 }

 $smarty->assign('smartyOption',$smartyOption);


 ## on your template side it should be something like this

 <select name="quantity">
 {foreach $smartyOption option}
 <option>{$option}</option>
 {/foreach}
 </select>

sorry I can't use your codes as example.. I can't just decipher the logic flows of your script.

veedeoo 474 Junior Poster Featured Poster

You are very much welcome. Just let us know if you need help in setting up the xampp package with ioncube loader.

veedeoo 474 Junior Poster Featured Poster

There is no guarantee that your data will remain encrypted. The reason is that if you distribute these encrypted data, the decryption must be supported by the browser and without internet connection. That leaves you to only one type of encryption method, the javascript encryption. This type encryption can be easily broken by anyone who can search the internet.

The second option is to distribute your application with lightweight xampp thumb drive edition, pre-stored your data with base64_encode.. this should give you an encryption very identical to the BLOB data. Actually, blob data seems to appear to me as just another derivative of base64 hashing. The downside of this if the user try to take a peek on the database, they can of course decode everything using a simple base64_decode function.

The third option is to utilize option two above, with the only exemption of not having a built in database in the distribution. The client only needs the ability to run pHP script on their desktop. However, this will require an Internet connection to retrieve data from your server.

The idea is simple, you just need to provide a unique ID.. the php script included in the xampp will then access the Internet and validate the unique ID with the remote server (your server). If the unique ID is valid, then the cURL in the local xampp gets executed to retrieved the decrypted data coming from your site.

The advantage of this is you have more control over the …

veedeoo 474 Junior Poster Featured Poster

Hi,

for the accents, we need to make a separate validation function for it.. e.g.

function isItLatin($username) {
$itIs = false;

if (preg_match("/^[\w\d\s.,-]*$/", $username)) {
    $itIs = true;
}

return $itIs;
}

Based on the accented character validation result, we can use different filters e.g. English, or Latin filters. So for instance, we have an accented input in the form, if the function above recognizes it as part of the acceptable characters within bound, then this

$username = preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['username']);

Will no longer apply or used, but instead we make the script by using the simple validation as included in the class itself

 ## this will allow usage of the accented characters
 $username = trim($_POST['username']);

For the javascript validation for accented characters, you can read more Here, it is pretty much self-explanatory..

rogerg commented: thx +0
veedeoo 474 Junior Poster Featured Poster

Later on, I will convert the entire script to either Twig or Smarty templating system. Depending on my mood. Twig is easy, so it is more likely to be the candidate. This will provide an additional security, because of the compilation use by smarty.

veedeoo 474 Junior Poster Featured Poster

If you downloaded the file before this post, you must donwload it again. I just made an update..

Update 2 Detail:

  1. Remove the restriction on password, so that the password generator can be use.

Safety issues on password?
1. Since the password is being converted to md5 hash, there will be few chracters or entities can pose harm to the database, the same hashing is used when validating the users password. The original santizing method is still in effect as intended by the original author.

ADDED file:

Here is the access control that will verify if the logded in member is an admin or regular member.

To be recognize by the script as admin, you need to change your privs as 7. The modification defined members privs as 7- admin, 3 - moderator, 1 - regular member. Script validates them as 700, 300, or 100.

veedeoo 474 Junior Poster Featured Poster

Hi,

Ok, just to get you going and to eliminate the problem of html tags being posted in the database. I fixed the class.. WARNING! this is a temporary fix.. I will attempt to fix some other vulnerabilities if I find ONE.

Disclaimer! I do not own NOR I wrote this log in system. I am still waiting for the original author to contact me if he has any updates for the script. Otherwise, I will have to make few more fixes, and this script should be consider as safe.

On my fixed file, I added a distinction between regular members and the admin. I also extended it to have a moderator role if needed be.

Later I will talk about this extended method from the original class.

Instructions:

  1. Download the upgraded fg_membersite file Here
  2. Replace the .txt extension with php extension. e.g. fg_membersite.php
  3. Open the include directory and rename the file called fg_membersite.php to something else. This is your backup file.
  4. Upload the downloaded and enamed file from step 1 and 2 to your include directory.
  5. Go to your phpMyAdmin, and then click on the database for your login system.
  6. On the top right corner, look for the sql tab, click on the sql tab.
  7. Place your cursor in the textarea, right click and then choose "select all", hit delete.
  8. Paste the codes below inside the textarea , and click save or go.

    ALTER TABLE member ADD privs INT( 11 ) NOT NULL AFTER name

  9. Now go …

veedeoo 474 Junior Poster Featured Poster

Hi,

I think there is a problem in the validation class of the script. I felt so guilty recommending this script. The earlier version I tested it, but their latest one, I have not do any testing at all. I should have test it first, before extending any recommendation. I need to contact the author of the script and tell him about this bug. He should be active at sourceforge..

I tested the script today and you are right, the html tags are able to scape and get posted in the database under the radar of the validator class.

If you can wait for a few days, I might be able to write you one, or maybe try to fixed the validation class..

I have a login function in my open source application, but it is too huge for me to disassemble for your purpose. Just hold on... I will get back to this thread.

veedeoo 474 Junior Poster Featured Poster

Hi,

Can you rewrite your js function so that the only thing left is to call that function. If so, you can do it like my example below. Not a big one, but that's how you make the php call for the output of the js function. unless, you want to wrap the entire js as php variable, then the possiblility is a little bit brighter. However, passing it in the script like your script above will not do it, because PHP is parse on the server side, while js is interacting on the client side.

<?php
echo "hello! I am echoed by php <br/>";
?>

<html>
<head>
<script type="text/javascript">
function displayDate()
{
document.getElementById("out").innerHTML=Date();
}
</script>
</head>
<body>

<p>Javascript ouput delivered by php </p>
<p id="out">Echoed JS function shows here.</p>

<button type="button" onclick="<?php echo 'displayDate()';?>">Clikc Me</button>

</body>
</html> 
veedeoo 474 Junior Poster Featured Poster

Hi,

This is just a humble suggestion.. I didn't really read your codes in its entirety, but I could see lots of improvements in the nested while loops area. You can try improving it by using mysql join. By using join, you might be able to get rid some of the while loops.

In my previous expermental application, I used singleton database connector class as shown ,,, Here. This can help a lot on the database function of your script, and this can serve as the CRUD on your application.

There is nothing wrong with nested while loops if there is no other way of avoiding it. So, don't force it, if it cannot be done with effeciency.

veedeoo 474 Junior Poster Featured Poster

copy, paste to notepad, save as anyNameYouWant.php, upload to your server, and then direct you browser to it.

  <?php phpinfo(); ?>

Look for the server API value and the loaded configuration file value..

  1. If Server API says anything about apache, then you can use the .htaccesss trick.

  2. If Server API says anything about CGI, fast CGI.. then you can add a new php.ini file in the root directory of your script. copy and save as php.ini and then upload to your server . Change 100M to your desired maximum upload file size. DO NOT use MB... this is very tempting in the minds of other to type MB.

        upload_max_filesize = 100M
        post_max_size = 100M
    
  3. Although not really necessary, except when you will be installing ffmpeg, mencoder on your server, then loaded configuration file value matters a lot. This is the php.ini file using by your server. This can be edited by way of SSH client like the PUTTY.

In most cases, people only need either 1 or 2 above.., but never both.

veedeoo 474 Junior Poster Featured Poster

Hi,
You can try logging in the admin first, and then generate a random security salt, assign this salt to session e.g. $SESSION['security'] = 1653e9gg4r99s@$7700)llls434rf853~, and then on your member's database table, you must insert this in session column. While the admin hops over pages, you can double check if the session salt still matches with the one recorded on the database. Session expiration will help also e.g. 45 minutes to generate a new salt, update database session column. Upon logout of the admin database session entries should also be unset. In my logged in sytem, I post salt as session, and then the IP address of logged in members.

veedeoo 474 Junior Poster Featured Poster

Hi,

I think your code will only take up to 6 thumbnails. To put more thumbnails, thumbnails needs to scroll ..There is a jquery that can do this. If my memory still serves me well, I think it was called jmycarousel it is free , and there is this jquery plugin written by makers of the flowplayer, it is called scrollable. Let me know if you need help in setting it up, so that I can help you writing the layout.

veedeoo 474 Junior Poster Featured Poster

Ok guy,

Here we go.. obviously I over slept up to the point where my professor sent someone in my dorm to wake me up.

I will just paste it here so that if other people may find this post useful, for whatever it's worth.....Ready?

Step One: In your htdocs directory, create a new directory called blob, inside the blob directory create another and name it uploads, and the rest are simple as copy and pasting. Copy sql below to create a new database table and name it "test". You are welcome to add more columns to your need.

 CREATE TABLE IF NOT EXISTS `images` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `image` longblob NOT NULL,
 `thumb` varchar(100) COLLATE latin1_general_ci NOT NULL,
 `title` varchar(255) COLLATE latin1_general_ci DEFAULT NULL,
 PRIMARY KEY (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci ;

The above sql is pretty common, with one EXEMPTION.. I used longblob. This will allow you to upload or store bigger files at least 3-5mb.

Step Two: Create a file named settings.php..actually this is just the database credentials file. pretty basic

 <?php
 ## filename settings.php
 $user = "root";
 $pass = "";
 $host = "localhost";
 $db_name = "test";
 ?>

Step Three: Create a new file called function.php

 <?php
 ## filename: function.php
 ## simple class
 function simple_func($sql){
 ## define your database connection credentials
 include 'settings.php';

$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
$db = mysql_select_db($db_name,$conn)  or die(mysql_error()); 

$result = mysql_query($sql, $conn) or die(mysql_error()); 
## we check and make sure we are getting a …
phorce commented: You are amazing lol. +4
veedeoo 474 Junior Poster Featured Poster

It's getting really late in my time zone .. not late it is already early in the morning,,, I'll just give you the files I have created in my localhost, before I head up for scholl in about 6 hours from now. I'm going to pick up a short snooze...

It includes upload capability, insert and retrieve to and from database as blob, then confirmation page where the uploaded file can be viewed as blob..

If I don't run out of time, I will also give you the blob thumbnails function I used for testing. Although I don't recommend using this function, because it is using too much memory I think people in this community deserve to see how it can be done..Just make sure you have the GD support enabled on your xampp, before attempting to run this script.

be right back later for this thread......my starbucks energy is slowly fading away....

veedeoo 474 Junior Poster Featured Poster

Images table has ID, Image itself, UserID(who uploaded that), Status and Date(Uploaded). I store images as BLOB

That refers to the id column of your images table. I use it, because you said you have an image table with id.. just replace it with whatever you have e.g. ID.. the view.php will use this id to send query to your database and show the single image.

I set up the query to pass the result $row into array $data[], then we loop this as $images. This is a good approach, especially if you will be separating the logic of your application from view. By setting it up like that, we can easily use any templating system that will come to mind at a later time. Setting it up with..not too much html mixing with the php codes. Mixing them in uncrotrolled proportion, will create problems in maintaining your application.

Because we are using php without the benefit the of any templating system, it is difficult to use the dot notation e.g. images.id . Templating system can easily achieve this, but that is out of the scope of this topic. It is nice to have the database connection be included in a simple function, so that if some time later, you need to re-write everything into simple class, the output of the query is already inside of a function. All you have to do is define the properties , and this simpe function is still in good shape working …

veedeoo 474 Junior Poster Featured Poster

Ok.. let's modify this one again . Sorry, it took me a while... my wireless keyboard ran out of battery. I need to recharge...

foreach($data as $images )
 {
 $img = $images['imageItself'];
header('Content-type: image/jpg');
 ?>
 <a href="location"><?=$img?></a>
<?php
 }

Change the above code to this

foreach($data as $images )
{


?>
<a href="view.php?id=<?=$images['id']?">View this image.<?=$images['id']?></a>
<?php
}

Then we can create a file view.php using your own codes above to show single image

 ## filename view.php
 ## add your database configuration file here

 if(isset($_GET['id'] && (!empty($_GET['id'])){
 $query = mysql_query("SELECT * FROM images WHERE id='".$id."'");
 $row = mysql_fetch_array($query);
 $content = $row['image'];

 header('Content-type: image/jpg');
 echo $content;
 }
 else{

 //do nothing this is just a test
 }

I set it up on my localhost like that and it is working... If it works for you, we just to make thumbnails so that you can use the thumbnails from the thumbnail directory as links..

ADDED LATER: I attempted to generate thumbnails from the blob . It was successfull, BUT it is using tremendous amount of memory. My test images sizes are 1mb, 2mb, and 10mb. For a much bigger database.. this will cause the mysql server to ran out of memory...I am running it on 16GB localhost. server type apache ->xampp on ubuntu..hard drive installed and not portable..

veedeoo 474 Junior Poster Featured Poster

ok, hold on let me write a working demo script for you to use.. including upload script.. I wrote something like this long time ago. It is in my hard. I just need to find it and set it up for live server.. Wait for a few minutes...

veedeoo 474 Junior Poster Featured Poster

Can you put up the snippet of your codes repsonsible for inserting image as blob? This has to be binary.. Just hold on let me write a simple script that will do this... I think we need to add header type .. Let try this first.

change this

 foreach($data as $images )
 {
 ?>
<a href="location"><img src="<?=$images['imageItself']?>" width = "100" height="100"/></a>
<?php
}

to this

 foreach($data as $images )
 {
 $img = $images['imageItself'];
 header('Content-type: image/jpg');

 ?>
<a href="location"><?=$img?></a>
<?php
}

What we are trying to achieve with the modified codes is to show images in their actual size. I also use the header php function. This may work... please let me know so that I can continue writing a demo if it does not work..

veedeoo 474 Junior Poster Featured Poster

This one Click Here. But it is not free though. With a little knowledge of basic php programming, you can probably create one for yourself.., then just implement the things you already know in ajax, css, html..

veedeoo 474 Junior Poster Featured Poster

I don't know if they still have it now, but this is the high school I graduated from 3 years ago.. Click Here., Where the future harvard, princetonian, caltech candidates are being created all year round in southern california..

veedeoo 474 Junior Poster Featured Poster

Have you ever consider php powered gallery? It is more manageable than just pure html gallery type.. PHP should be able to give you the options to edit, delete, or even upload your files...

veedeoo 474 Junior Poster Featured Poster

If we want the page containing the images to be inserted in an iframe, then you can create the page dynamically..or write a simple php function to retrive the images data from the database and call it within the iframe.

example of dynamically created page. Let's say, we have a page called iframecontents.php.. this is the file that will be called by the iframe ... e.g.

<iframe src="iframecontents.php"></iframe>

Let's make sense out of the iframecontents.php..

  ## filename : iframecontents.php

  ## normally, I get pretty lazy this time of the day, but I am fighting for it as much as I could, let us write a simple function. I want it reusable at any page if needed be.

  function show_images($sql){
  ## define all of your database credentials below
  $db = "someDb";
  $db_host = "localhost";
  $db_user = "someUser";
  $db_pass = "somepassword";


  ## let's connect to database..
  $connect = mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());
  $db = mysql_select_db($db,$connect)  or die(mysql_error()); 
  $result = mysql_query($sql, $connect) or die(mysql_error()); 

  ## now that we are connected we can loop through the result

  while($row = mysql_fetch_array( $result )) 
  {
  $data[] = $row;
  }
  ## we return the data

  return $data;

  }  
  ## end of our little function

  ## code below is responsible for generating the actual result given by query..

  ## define the query
  $query = "(SELECT * FROM images )"; 

  ## call the function above
   $data = show_images($query);
    ## iterate through the results returned by the function 
   foreach($data as $images ){
      ?>
      <p><a href="location"><img src="<?=$images['imageItself']?>" width = "100" …
veedeoo 474 Junior Poster Featured Poster

Hi,

try reading this one Here. That is one of many implementation I found.

While this one Here is pretty good I think. It all depends on how fancy you want it to be..

veedeoo 474 Junior Poster Featured Poster

Hi,

In response to question 1, you have two options here. First is storing the images as BLOB(which I don't really recommend, unless you have a superly expensive copyrighted images.) , second, just have the image filename stored in database.

Say you have a database called image, and this image table have the following columns id, name, status, access. Simple explanations of columns: id is set to auto-increment, name is for the filename e.g. somejpg.jpg, status can be set to true or false, and finally access can be set to public or private.

Using the above image's parameters, we can then build our database query based on those columns. e.g. select from image where status='true' (this pull out all of the images with the status set as true).

For question two, You don't have to use iframe for this type of application, you can just send query to the database and just iterate the results, thus showing these results on the page.. Again I am assuming here that you already have a database setup for your members, and a login system to validate your users.

Depending on your login system validation for members logged in or not.., we can use a query based on this validation like

 if ($loggedIn){
 ## we make the image href url live
 echo '<a href="locationOfYourImages/'.$row['name'].'.jpg"><img src="locationOfThumb"/></a>';

 }
 else{
 ## show thumbnail without link

 ## if you allow the public to view sample images, just to intice prospective new members

 ## you can then show …
veedeoo 474 Junior Poster Featured Poster

Hi,

Just place your cursor before > and then hit back-space . I think the arrow operator has been separated. Do the same on line 20. -> should not be separated as shown on your codes - >

veedeoo 474 Junior Poster Featured Poster

Hi,

Yes you can do it.. here is sample. This example demonstrate how to assign array in session.

1.php

<?php
session_start();
   ## page one
   $sku = "12345678_SKU";
   $itemID = "580007";
   ## make sure the above are not empty
   if((!empty($sku))&&(!empty($itemID))){

   $itemAr = array( $sku, $itemID );
   $_SESSION['items'] = $itemAr;

   }

   echo '<a href="2.php">Go to page 2</a>';
?>

2.php . I am not a big fan of php shorthand tags, but I will use it here..

 <?php
   ## filename 2.php
   session_start();
   ## let's access items in the session and move them to form input
?>
   <form method="post" action="3.php">
    <p>
   <label>SKU</label>
   <input type="text" name="sku" value="<?=$_SESSION['items'][0]?>"/><br/>
   </p>
   <p>
   <label>Item ID</label>
   <input type="text" name="itid" value="<?=$_SESSION['items'][1]?>"/><br/>
   </p>
   <p>
   <input type="submit" name="submit" value="Next"/><br/>
   </p>
   </form>
   <!-- end of form -->

3.php This file demonstrate how we can unset session for specific array assign to it, and then assign a new set of array.

 <?php
   ## filename 3.php
   session_start();

   ## since that this page is now relying on the items submitted in the form, we can unset our session['items']


   if((isset($_POST['submit']))&& (!empty($_POST['sku']))&& (!empty($_POST['itid']))){
   ## unset session from two previous page to set these form items
   ## if browser is going to go back and forth between pages, do not unset the first session, instead create a new one.
   unset($_SESSION['items']);

   ## I added a suffic -> _two on the posted items, for 4.php checkpoint. We want to make sure the session has been unset if wa
   ## we want it unset.
   $sku1 = $_POST['sku']."_two";
   $itid = …
LastMitch commented: Thanks for the example! +2
veedeoo 474 Junior Poster Featured Poster

You can also do it this way...C++ style... The $z is rolling in its own grease a 100 times ..

  <?php
  call_user_func( $x = function( $yx, $z =1 ) {
echo (string)("Hello World <br/>"), $yx[floor($z/100)]($yx, ++$z);
}, array( $x, function(){} ));

?>
veedeoo 474 Junior Poster Featured Poster

you have too many un-necessary statements and queries. Remember, you are only validating ONE member, one password, one ip, and lastly one id.

Your first query to validate user should be enough,.. Checking the id don't make sense. Especially, if the id is auto incremented on your database. It does not help and will not help at all..

**session_register is long gone and depricated sometime ago.. **

Hold on, let me rewrite your codes..

NEVER MIND you already marked this question as solved...

veedeoo 474 Junior Poster Featured Poster

Hi,

Can you double check what is the column name on your database? This should be called id.. remember this is a case sensitive.. make sure the id in your query matched the actual mysql database column name for the id..

veedeoo 474 Junior Poster Featured Poster

Hi,

I think you need to focus more on validating which submit buttons were click. You have two of them. If I click one only, then on POST, you will get the undefined index error on the other.

Why not try validating your form submission based on the submit button clicks. for example

  if((isset($_POST['save1'])) || (isset($_POST['save']))){

   ## check here which one is not empty, and then prepare it for the database inclusion or posting.


  }

Please forgive my vigorous use of parenthesis. I can't just help it and it is becoming more of a second nature to me overtime, it is probably because of my mathematics background and calculator projects I have been working on and in the past. In mathematics, extra care is needed in isolating integers and variables, so that the program will calculate based on the PEMDAS convention. Otherwise, the calculated output is inaccurate, and others will not be able to replicate it.

veedeoo 474 Junior Poster Featured Poster

ok, here is the second part. All you need to do is put back the css styling on your html codes. This should work..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!-- put back your css styling here -->

<title>pagination
</title>
</head>
<body>
<div id="container" class="round10">

<?php 
include_once 'includes/header.php'; 
include_once 'includes/sidebar.php';
?>

<div id="content" class="left round10">

<h1><img src="images/images.jpg" width="30" height="30" /> &nbsp; Student List</h1>

<div class="box box-info">Please click the name of the Students if you want to send them a message</div>
<div align="right">
<a href="search.php">
<u>Search Student?</u>
</a>
</div>

<?php
/*
Place code to connect to your DB here.
*/
include('config2.php'); // include your code to connect to DB.
## include pagination script 

include ('pagination.php');

$tbl_name="account_student"; //your table name

## count rows from database for pagination.
$query = "SELECT COUNT(*) as num FROM $tbl_name";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];

## pagination settings
$adjacents = 5;
$limit = 5; //how many items to show per page
$targetpage = "view_student_account.php"; //your file name (the name of this file)


if(isset($_GET['page'])){
    $page = $_GET['page'];
    $start = ($page - 1) * $limit; //first item to display on this page


    }
else{
    $start = 0; //if no page var is given, set start to 0
    $page = 1;
}

## initialize pagination
$pagination = vpagination($total_pages);

$sql = "SELECT id, fullname, course, year, section, year FROM $tbl_name LIMIT $start, $limit";
$result = mysql_query($sql);

## do not put strain on your server by echoing html tags. Just close the …
veedeoo 474 Junior Poster Featured Poster

Hi,

Please don't call me sir. I just barely turned 19 years old. :) . On the other hand, I always think I am already old, but my parents said not yet. "You are just barely getting in there young man".

Thanks a lot though, I really appreciate it, must be a sign of respect. We don't get that much here in the States. We call each other Dude, or something really geeky in that regards..

Ok, back to your problem, I will do this in two parts.

First, I tried to work on you pagination script, but I think it is missing some features I would like to see in pagination script. I modified some pagination scripts that I stumbled upon on the Internet. I really don't know who was the original author. I think it was 4 to 5 years ago. Overtime, I was experimenting on how to improve this script. However, I think it already maximized its potential that it is now pretty old for me to use in my applications. However, this script has been helpfull to me years back.. It just need 1 variable and 5 globals.

Here we go...copy codes below, save as **pagination.php
**

<?php
function vpagination($numrows){
global $page,$start,$limit,$adjacents,$targetpage;

## edit based on the global assigned above ##
$rowsperpage = $limit; 
$range = $adjacents;


## do not edit beyond this line ----------------------##
$page_v = "";
## calculate total pages
$totalpages = ceil($numrows / $rowsperpage);
## get current page or set a default …
veedeoo 474 Junior Poster Featured Poster

Hold on, let me run a test on my editor..

veedeoo 474 Junior Poster Featured Poster

Hi,

This is just a suggestion. Why not remove your pagination script first. Go back to where your script works. Then create a pagination class. If you are not comfortable with writing a class just write it in the simplest form.. like this

  ## filename: pagination.class.php ##

  class PageIt(){

  ## we don't have to define any var here, because this is just a simple class to get you going.

  ## create the pagination function

  function doPagination($total_pages){
  ## since that this is a simple class at the very minimum, we can set our globals below. Otherwise these items must be difine as var above.
  global $tbl_name, $start, $limit;

  ## put your pagination script below,WITHOUT the database query in it. I mean both of them must not be included here. Explanation will be provided below.



  ## this will return the .pagination

  return $pagination;
  }


  }
  ## end of this tiny and simple class

Like what I have already commented inside our little tiny class above, we need to remove and send query to your database here..

   include 'pagination.class.php';
  ## top section of your script here before the while loop.


  ## first do a count query Remember! $tbl_name is global, and has to be define above this section of the script.

   $query = "SELECT COUNT(*) as num FROM $tbl_name";
   $total_pages = mysql_fetch_array(mysql_query($query));
   $total_pages = $total_pages[num];

   ## we instantiate our simple pagination class.
   $page_it = new PageIt;
   $paginate = $page_it->($total_pages);

   ## now our pagination above is ready.. we do the second …
veedeoo 474 Junior Poster Featured Poster

Correction,. not auto increment.. and the first query should be corrected once again to add the id. The same id as in the old table and the archive. Without out this we won't be able to request any result

$result= mysql_query("INSERT INTO archieve (id,username, password, fullname, course, year) SELECT id, username, password, fullname, course, year FROM account_student WHERE id='".$id."'")

The query above should post the item in the archive table with the same id value as in $id..

Sorry about that... I must be pretty tired already or just having a weekend fever.. I will look at this again tomorrow... I out of here...

veedeoo 474 Junior Poster Featured Poster

Please observe the $result2 .. I just updated the codes above... I don't want the two results colliding each other...

veedeoo 474 Junior Poster Featured Poster

The problem in the mysql_fetch_array(), I just realize that when you insert something from another table to a new one, once the query is execueted.. it is done.., and we won't be able to pick up the result..

Before goin on further, on your achive table, is the id set as auto increment??? Make sure that it is set to autoincrement otherwise, the archive table will not have an id value.

To check if the insert to the archive table has been executed. Using the php admin take a look at the archive table.. I am pretty sure , even with the error above.. the script managed to insert..

to fix the error above, we need to create a query specific only to the inserted values on the archive table.. However, if the ID on the archive is not set to auto increment the query below will bring another error. So, please double check..

Here is the new query for the newly posted data on the archive. This will serve as a confirmation on what was posted by the first query.

     $result2 = mysql_query("SELECT * FROM archieve WHERE id='".$id."'")
      or die (mysql_error());          
      while ($row = mysql_fetch_array($result2))

     {
     echo '<td><center><a href="write_message.php?id=1">' . $row['fullname'] . '</a></center></td>';
     echo '<td><center>' . $row['username'] . '</center></td>';
     echo '<td><center>' . $row['password'] . '</center></td>';
     echo '<td><center>' . $row['fullname'] . '</center></td>';
     echo '<td><center>' . $row['course'] . '</center></td>';
     echo '<td><center>' . $row['year'] . '</center></td>';
     }

Before running the updated script above make sure to delete the entry on …

veedeoo 474 Junior Poster Featured Poster

HI,

You need to remove the * from your select. Try using this

   $result=mysql_query("INSERT INTO archieve (username, password, fullname, course, year) SELECT  username, password, fullname, course, year FROM original_table WHERE id='$id'")

Don't get too agressive on your DELETE query.. YOu need to make sure that data has already been posted on your achive table.

Put the delete query somewhere else, not on the very top..

veedeoo 474 Junior Poster Featured Poster

I wish I could help, but Biim already got it under control, and doing a hell of an excellent job .. :) At the least, I managed to provide my humble contribution of a short definition of vegetables and fruits... :)

You can also put your important values in session as an array.. for example,

  $_SESSION['important'] = array($data1, $datat2, $data3,$data4, $moreHereIfyouWant);

Then you can easily access session items from the array by

   $_SESSION['important'][0]; // for data1
   $_SESSION['important'][1]; // for data2
   ## add as many as you want.

Not much of a contribution from me, but I hope it can be considered..

Honestly, it is looking pretty good guys...

veedeoo 474 Junior Poster Featured Poster

Hi,

Try changing this

 $query = "SELECT * FROM interviews WHERE vacancyid = $applyid'";

To

 $query = "SELECT * FROM interviews WHERE vacancyid = '$applyid'";

Double check your queries above and do the same..

You can also change your code to this...

 if($row["vacancyid"] == $applyid)
 {
  ## show your form here
  }
  else{
  echo "no interviews are be held";

  }

It is a lot easier for your script to evaluate the $applyid equal to vacancyid, because applyid is your parameter in your query. It could have been an easy query, but since you need to echo the form with values from the same query, we don't have a choice but loop over.

veedeoo 474 Junior Poster Featured Poster

ok, thanks for posting your codes.. now I need to see how your database table are structured. This will be the target database for your search query. I am expecting something like this..

Datatbase Name: Automobile
tables:
vehicle =>columns : id --- name -- title -- year -- model -- poster --- date posted -- etc..etc.

If you another table/s to list just list it here..

veedeoo 474 Junior Poster Featured Poster

What is the error message you are getting? Another possible problem is the db class. Are you using a database connection class? If so, what is the name of the class? Look for something like this..

class Something{

// more stuffs here
function someFunction(){

}
}

In my example above, the name of the class is Something, In your case it can be any name, look on your headerloggedin.php file and find ** $db = new Something();** Something is the name of your database connection class.

Make sure the class responsible for connecting, fetching, updating, inserting to your database in included and instantiated..

veedeoo 474 Junior Poster Featured Poster

Hi,

Can you load the actual file of this script on your editor and tell us what is on line 51?

veedeoo 474 Junior Poster Featured Poster

try using single qoute for the double quotes and double quoutes for the single quotes. Otherwise, yo can escape it. Another alternative is to use heredoc for a longer string., but for your situation something like this will do..
<?php
echo '"';
echo "' '";
?>

veedeoo 474 Junior Poster Featured Poster

You can scale the image based on the proportional ratio of your maximum width and the actual height. However, if we properly scale 452x507 to your maximum dimension. The properly scaled output will only be around 54.21px by 60.84 px.

Here are the reasons why?

To scale we need to check if the actual image is a wide image or tall image. To find out if the image is either one, we need to put the actual image dimension into simple calculation.

let x = width, and y = height.

Image is wide if(x > y), and image is tall if(y > x).

If the image is tall, then we can properly scale the image by calculating the slope or in this case the quotient of the maximum height vs. the actual height of the image. Therefore, in our case the quotient can be presented by this simple formula.

let max_y = 61px, and max_x = 235px

calculate quotient => mq = (max_y) / (y) => (61px)/ (507px) = 0.12

calculate the scaled width => final width => x * mq => 452px * 0.120 = 54.24px for the output width

calculate the scaled height => final height-> y * mq => 507px * 0.120 = 60.84 px or round it 60px.

If you want me to translate the above calculation in php script to work with images , please let me know..

veedeoo 474 Junior Poster Featured Poster

Hi,

You mean like this?

link -->link is clicked -> use "link" string as part of the database query -> script returns result based on the query

So, for the above logic the query can be something like this -> select from link, or select from some table where something is equal to link.

Is that it?

If that is what you need you could either grab the link string from the database OR take it from an array. It is reverse of what you have in mind.

veedeoo 474 Junior Poster Featured Poster

Hi,

Shared hosting does not allow direct php.ini file editing. However, you are allowed to add entries to either .htaccess file or create a new php.ini file, depending on your server's API. There are cases where additional entries are needed to be included in .htaccess file, and others has to go on php.ini file. Even with this given option, there are some settings that you can't just change like adding extensions e.g. someextension.so.

Copy codes below, paste it your code editor, save as anyNameYouWant.php, upload this file to your server. Direct your browser to this file..

<?php

   phpinfo();


?>

Look for the value of "Server API", and post it here. I am expecting a value of either apache module, apache, CGI, or fast CGI. Based on the API loaded on your server, I can tell you where add your enties.