Latest Programming Posts

Often understanding why something is done a certain way can often help.

Set yourself a project goal, make it something you don't currenly know how to do. It's okay to google your way through it but just remember when you copy/paste code from forums etc. try understand what the code is doing. Look up the functions and what they do.

W3Schools is great at explaining it in great detail with examples you can mess with to help get your head around things.

Learn from each project you build and improve on it, you will only get better as a result.

Alway remain inquisitive

I'm not sure that it's the OP's fault that there was no provision for editing the website from the author.

Well there's obviously not talked about it in their first meetings :) The OP probably thought that a CMS or any kind of system to add/edit content easy on other pages then the webshop was included and the author probably thought that the OP was reaching out to him to do any changes or additions to the content, so he can charge some exrea fees.

From my understanding the OP wants to edit/add content indeed like in a Dreamweaver Design View functionality and he doesn't wanna juggle with programming languages, but even working with Dreamweavers Design View needs some learning curve especially when there are dynamic pages and databases involved.

Either way the OP needs to get his hands dirty or he just let the author do the content changes/additions for an extra fee. If it's only so now and than some changes/additions, then why be bothered by investing time into learning all these stuff. Adding an introduction to the homepage is 5 minutes work for the author.

It's not up to anyone but you to pick a topic. Have you ever seen Howie Mandel (in his old stand-up days) doing improv?

  1. OK guys. Give me an occupation.
  2. Now give me a city.
  3. Now give me a situation.
  4. Now give me some funny things to say.

If you don't have any ideas then maybe you are studying the wrong thing.

Also, by now you should have learned how to do research. A great part of that involves reading. I mention that because if you'd read the Please read the Daniweb Posting Rules you might have noticed the part about hijacking/reviving old threads.

In your post is " review your lesson" which I find interesting. This class should have been building up to this bigger app. Where are you with this assignment? Are you stuck with a specific step?

commented: im stuck with a specific step i dont know what to do with it, im just a newbie on this program c ,i dont know what to start (T.T) +0

im just new on c program

can you help me on this ?

problem :
make a C program that will ask 10 numbers and store into an array. the numbers to be entered must be between 70 to 95 only

output the average,number of grades below average, above average. if more grades are below average , will display " review your lesson" else " proceed to next chapter "

I'm not sure that it's the OP's fault that there was no provision for editing the website from the author. I'm not convinced that you need a fully-fledged IDE. The number of options and menus can be bewildering.

What you may need:

FTP client like Filezilla (free) for uploading/downloading files

Editor like Notepad++ (free), there are a number of others available

An editor like Notepad++ should suffice
A stack solution like XAMPP (free) can be useful for testing your site locally

A GUI like SQLyog (community version, free) is a lot easier to use than phpMyAdmin

There are other bits and bobs you may find useful, but those are the bare bones, I think.

hello guys!!
i need some help here...
i don't have a specific topic proposal...
my topic is using wedsite for our online uniform

i am stiil studing

I don't see that $link has been set (line 13). In any case, the error means you are processing 0 entries at line 23.

The best "on the cheap" solution is quite involved:

  1. Download Dreamweaver from here:
    (It's an oldie but goodie freebie).
  2. Download USBWebServer from here:
    What you are going to do is create a complete test copy of your website to practice on. If your website is PHP, then you should be able to copy the folder that contains index.php. You will also need the MySQL database (which might contain all the text entries).
  3. Using these copies, create your "test environment" on your USBWebServer localhost.
  4. Point Dreamweaver to your environment. It will give you a wysiwyg editor, and should show you where you need to modify your text.

If you can't make that work, you will need help.

If you are giving out assignments be sure to tell if this is something you are looking for coders and what the pay is. Your post is either that or just someone that copy/pasted their homework assignment. finds it's been kicked around before.

Also, this smells of the old pSOS system.

1) Choose the time quantum and assign it for each process.
2) Allocate the CPU to the process according to the FCFS scheduling.
3) If (burst time of the process < time quantum).{Allocate the CPU to that process till it terminates.}Else {The process will occupy the CPU till the time quantum and it is added to the tail of the ready queue for the next round of execution.}

What is the code of this Algorithm in c++.

the  following  states  have  been  executed  in  the CPU Scheduler
1. When a process switches from the running state to the waiting state.
2. When a process switches from the running state to the ready state
3. When a process switches from the waiting state to the ready state
4. When a process terminates

I've worked with MIPS before and I continue to find the best way to get there is with a C compiler. There's just not enough gain to write in pure assembler for such small tasks.

lnstead of using a textbox to get a folder path use the appropriate control provided by the NET Library. It is called FolderBrowserDialog TextBoxes are not very good for this kind of operation. The user could have a lot of problems typing a correct path, instead a FolderBrowserDialog in its simplicity allows to reach the correct path without manually typing anything

Dim fbd = New FolderBrowserDialog()
fbd.Description = "Select a folder for the new database"
fbd.RootFolder = Environment.SpecialFolder.MyComputer
fbd.ShowNewFolderButton = True
If fbd.ShowDialog() = DialogResult.OK Then

    Dim filePath =  Path.Combine(fbd.SelectedPath, "N.mdb")
    Dim cat As Catalog = New Catalog()
    cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=" & filePath & _
                "Jet OLEDB:Engine Type=5")
    MessageBox.Show("Database Created Successfully")
    cat = Nothing
Catch ex As Exception
    MessageBox.Show("Database already Exists")
End Try

End If

Include database (line 9) should be outside of object User because in line 11 you define reference to db connection which is lost after comlete user construct

I am trying to implement a MIPS code that preforms unsigned integer divide but i couldn't figure out how.

if D == 0, report an error and terminate.
Q = 0 # Q is the quotient, initialized to zero
R = 0 # R is the remainder, also initialized to zero
n = the number of bits in the numerator N

That is, the number 3710 is 1001012 has 6 bits.

Shift through the bits of N to find the

position of its most significant 1 bit.

Write a separate function to determine “n”.

for i = n-1, n-2, … 0 do
R = R shifted left one bit
R[0] = N[i] # The least significant bit of R is

set to bit i of the numerator N.

if R >= D then # Test if R is greater than or equal
R = R – D # to D. If so, subtract D from R and
Q[i] = 1 # set the ith bit of Q to a one.
return Q, R # Return the results to the caller.

Hi guys so ive been taking a python 3 class this semester and im having some trouble. so here is the problem.
Create a python script that stores 20 random integers from 1 to 100 into a file delimited (ie. seperated) by commas (,).

For example; if you cat the file when you are done, it should look similar to the following:

cat numbers.txt

Create a script that read in the text file from PRx0D.
It should take the data and put each integer into a list.
Eg: [61,8,46,71,9,95,77,62,69,6,97,97,77,96,95,20,89,31,3,23]
It should then display the following information from the list:


I have the program that generates 20 random numbers from 1-100 but i have no idea how to grab the text file and have it read in that way.
I have been trying for a few days now but i just dont get it. I am more of a web designer not a very good programmer. thank you if anyone can help!
what i have complete so far is below.

   import random 

def Rand(start, end, num): 
    res = [] 

for i in range(num): 
    res.append(random.randint(start, end)) 

return res 

num = 20
start = 0
end = 100
print(Rand(start, end, num))

What's a good program to use to edit it though?

Look... you should've asked the person who made the website for you, before he started the job, hoiw you can easily edit the website. But you didn't and now you're stuck with a static website that can only be edited by someone that knows how to do that through a code/text editor like your Firstpage editor.

commented: Better explanation than mine! +15

"What's a good program to edit it though?"

That needs more detail. Here I've used notepad, notepad+, Visual Studio's editor, and countless other editors. Since when we deal with code, there is no perfect editor I tend to use the one I have available.

What detail? Once in awhile a new to coding person wants the editor to do a lot more than edit a file. They want it to have syntax checking and more. But for editing, it really doesn't take much.

What's a good program to use to edit it though?

When I run script I get error

Fatal error: Uncaught Error: Call to a member function prepare() on string in /Applications/MAMP/htdocs/sae/TT/public_html/includes/user.php:21 Stack trace: #0 /Applications/MAMP/htdocs/sae/TT/public_html/includes/user.php(40): User->emailExists('') #1 /Applications/MAMP/htdocs/sae/TT/public_html/includes/user.php(102): User->createUserAccount('userr', '', '123456789', 'Admin') #2 {main} thrown in /Applications/MAMP/htdocs/sae/TT/public_html/includes/user.php on line 21

Please have a look in code and help me find out error.

        ini_set("display_errors", 1); error_reporting(E_ALL);
        class User
            private $con;

            function __construct()
                $db = new Database();
                $this->con = $db->connect();
                // if ($this->con) {
                //  echo "COnnected";
                // }

        // Check user 
        private function emailExists($email)
            $pre_stmt=$this->con->prepare("SELECT id FROM user WHERE email = ? ");
            $pre_stmt->bind_param("s", $email);
            $pre_stmt->execute() or die($this->con->error);
            $result = $pre_stmt->get_result();
            if ($result->num_rows>0) {
                return 1;

            } else
                return 0;



    public function createUserAccount($username,$email,$pass_hash,$usertype)
        if ($this->emailExists($email)) {
            return "EMAIL_ALREADY_EXISTS";

            $pass_hash = password_hash($password,PASSWORD_BCRYPT,["cost"=>8]);
            $date = date("Y-m-d");
            $notes = "";
            $pre_stmt = $this->con->prepare("INSERT INTO `user`(`username`, `email`, `password`, `usertype`, `register_date`, `last_login`, `notes`) VALUES (?,?,?,?,?,?,?)");
            $pre_stmt->bind_param("sssssss", $username, $email, $pass_hash, $usertype, $date, $date, $notes);
            $result = $pre_stmt->execute() or die($this->con->error);
            if ($result) {
                return $this->con->insert_id;
            } else {
                return "SOME_ERROR";


    public function userLogin($email,$password)
        $pre_stmt = $this->con->prepare("SELECT id,username,password,last_login FROM user WHERE email =? ");
        $pre_stmt->execute() or die($this->con->error);
        $result = $pre_stmt->get_result();

        if ($result->num_rows <1) {
            return "NOT_REGISTERD";

            $row = $result->fetch_assoc();
            if (password_verify($password,$row['password'])) {
                $_SESSION['userid'] = $row['id'];
                $_SESSION['username'] = $row['username'];
                $_SESSION['last_login'] = $row['last_login'];
                // updating user last_login

                $last_login = date("y-d-m h:m:s");
                $pre_stmt = $this->con->prepare("UPDATE user SET last_login = ? WHERE email = ? ");
            $result = $pre_stmt->execute() or die($this->con->error);
            if ($result) {
                return ...

Line 26 is saying adminid should be padded in via a GET request (ie query string) but the page is being requested without ?adminid=x

Ah, thanks. I think my problem is I have a race condition with some AJAX. I'm initiating a request before a previous request completes. However, I'm using session_write_close() immediately after retrieving session data when the script first runs, so it should be releasing the lock before doing any heavy lifting.

The bugs I linked to are present in the PHP Redis driver, phpredis.

CodeIgniter's Sessions functionality uses it to connect to Redis. There is even a caveat in the documentation stating

Since Redis doesn’t have a locking mechanism exposed, locks for this driver are emulated by a separate value that is kept for up to 300 seconds.

Those links appear to be related to native PHP sessions. Codeigniter rolls its own session library that implements locking differently than native PHP does.

MySQLi method is shown in my first respond.
If you use bindParam() (PDO method - my second respond) $con should be PDO object.
Read and


I would like to ask a question about returning the column value(s) returned by stored procedure in c#. I have created the code but somehow I encountered an error saying:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

Here is my code

      public void Display(string pdesc, string psdesc, string psize, string category, ListView lv)
            queryString = "execute dbo.sp_RunningBalance @desc, @sdesc, @cat, @size";
            SqlCommand cmd = new SqlCommand(queryString, cn.con);
            cmd.Parameters.AddWithValue("@cat", category);
            cmd.Parameters.AddWithValue("@desc", pdesc);
            cmd.Parameters.AddWithValue("@sdesc", psdesc);
            cmd.Parameters.AddWithValue("@size", psize);
            SqlDataReader rd = cmd.ExecuteReader();

            while (rd.Read())
                var ctrl_listviewItem = new ListViewItem();
                ctrl_listviewItem.Text = rd["EntDT"].ToString();
                ctrl_listviewItem.SubItems.Add(rd["InventoryID"].ToString()); // Inventory ID
                ctrl_listviewItem.SubItems.Add(rd["Qty"].ToString()); // Qty
                ctrl_listviewItem.SubItems.Add(rd["UOM"].ToString()); // uom
                ctrl_listviewItem.SubItems.Add(rd["Balance"].ToString()); // balance
                ctrl_listviewItem.SubItems.Add(rd["Status"].ToString()); // status
                ctrl_listviewItem.SubItems.Add(rd["Remarks"].ToString()); // remarks


Please help me with the error

Thank you in advance :)

Hello everyone! I'm new here and I really need some helps regarding my php coding. I'm trying to do an Update page and the error keeps popping out "Undefined adminid". I've been trying to fix it but to no avail. Can you help me?

    //my database connection
        $host = "localhost";
        $user = "root";
        $password = "";
        $db = "eat";
        $conn= mysqli_connect($host,$user,$password, $db);
        mysqli_select_db($conn, $db);

   //my AdminSetting.php

    $query = mysqli_query($conn,"select * from admin");
    $row = mysqli_fetch_assoc($query);

     <fieldset class="account-box">
            $status = "";
            if(isset($_POST['new']) && $_POST['new']==1)
                $name =$_REQUEST['name'];
                $email =$_REQUEST['email'];
                $phone = $_REQUEST['phone'];
                $address = $_REQUEST['address'];
                $update="UPDATE admin SET admin_name = '$name', admin_phone = '$phone', admin_address = '$address', admin_email = '$email' where aid='".$id."'";
                mysqli_query($conn, $update) or die(mysqli_error());
                $status = "Record Updated Successfully. </br></br>
                <a href='view.php'>View Updated Record</a>";
                echo '<p style="color:#FF0000;">'.$status.'</p>';
            else {
             <form class="account-form" action="" method="POST" >
                <p>This is your private area. Please keep your information up to date.</p>
                <div class="account-content">
                   <input type="hidden" name="new" value="1" />
                 <input type="hidden" name="adminid" value="<?php echo $row['aid'];?>"  />

                   <p><label>Name:</label> <input type="text" name="name" size="30" maxlength="30" value="<?php echo              $row['admin_name'];?>"   /></p>
                   <p><label>Email Address:</label> <input type="email" name="email" size="30" maxlength="30" value="<?php echo $row['admin_email'];?>"  /></p>
                   <p><label>Phone Number:</label> <input type="tel" name="phone" size="30" maxlength="30" value="<?php echo $row['admin_phone'];?>"  /></p>
                   <p><label>Address:</label> <textarea type="text" name="address" rows = "4" cols = "50" value="<?php echo $row['admin_address'];?>" ></textarea></p>
                 <div class="save-btn">
                     <input type="submit" name="submit" value="Update"/>
   <?php } ?>

Looks like this has been a problem in PHP for a long time. On a brighter note, it looks like a fix is on the way.

@Talib_1 this is (procedural) MySQLi method not PDO. The PDO would look something like this:

$stmt = $con->prepare("INSERT INTO table(id,s_id,date,time) VALUES (null,:s_id,:date,:time)");
$stmt->bindParam(':date', $date, PDO::PARAM_STR);
$stmt->bindParam(':time', $time, PDO::PARAM_STR);
foreach($s_id as $val){
    $stmt->bindParam(':s_id', $val, PDO::PARAM_INT);
commented: Thanks @AndrisP for your answer, I used this code appear(Fatal error: Call to a member function bindParam() on boolean) at line 2, how fix it? +0

The auth:api middleware will handle the passport token authentication and the sellers middleware will check if users are sellers. I think you are getting mixed up with the way the middleware is set up.

This sort of depends on how you have your user types set up but in your sellers middleware you can check for User types / roles:


namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Guard;

class Sellers

 * The Guard implementation.
 * @var Guard
protected $auth;

 * Create a new filter instance.
 * @param  Guard  $auth
 * @return void
public function __construct(Guard $auth)
    $this->auth = $auth;

 * Handle an incoming request.
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
public function handle($request, Closure $next)
    if ($this->auth->user()->is_seller) {
        return $next($request);

     return response()->view('errors.401', [], 401);

Then you can set your route up to use both auth:api and sellers middleware:
So now if a normal user tries to access the get-seller-detail route it will return a 401 unauthorized error and if a seller tries to access this route it will proceed to the code for that route as normal.