minitauros 151 Junior Poster Featured Poster

Have you tried opening a new window with Javascript? You can use the window.open() function for that, if I'm not mistaken.

minitauros 151 Junior Poster Featured Poster

You start a session with session_start(). That should probably be one of the first lines, if not the first line, of any of your files in which you want to use the session.

Then, after starting the session, you can save values to it or retrieve values from it, using $_SESSION. E.g.:

Page 1:

<?php
session_start();
$_SESSION['test'] = 'hello';

Page 2:

<?php
session_start();
echo '<p>The session value for test is now: ' . $_SESSION['test'] . '</p>';

Hope that helps a bit ;). If not, have you tried searching Google for tutorials on PHP sessions?

minitauros 151 Junior Poster Featured Poster

Well it seems like this should be working. Only thing that I see is wrong (in case you haven't found it yet yourself) is the misplacement of your semicolon on line 23. It shouldn't be include ("inc/OutletsIn" . $country_selected .".php";) but include ("inc/OutletsIn" . $country_selected .".php");.

minitauros 151 Junior Poster Featured Poster

In line 2, you are comparing session to null. However, firstly, there is an error in your code here, as "session" is no PHP language. It should either be $session or $_SESSION. If you want to check if a session has been started, I recommend you use session_id() to check that, instead of just $_SESSION.

Secondly, you are now returning some HTML. I would rather return true or false, and then echo some HTML according to if true or false is returned when you execute the function.

Third, you are not executing your function correctly in your HTML. Instead of executing the function, you are redefining it. You could try this:

<?php
public function isLoggedIn() 
{
    if(!session_id()) {
        // No session ID has been set.
        return false;
    }
    else {
        // Session ID has been set.
        return true;
    }
}
?>

<ul>
    <li><a href="index.php">Home</a></li>

    <?php
    $is_logged_in = isLoggedIn();

    if($is_logged_in) {
        echo '<li><a href="login.php">Login</a></li>';
    }
    else {
        echo '<li><a href="logout.php">Logout</a></li>';
    }
    ?>

    <li><a href="allstock.php">All Our Stock</a></li>
</ul>
minitauros 151 Junior Poster Featured Poster

If you are still looking for a regex, something like this might work:

/\[url\](?!\[url\])(.*?)\[\/url\]/is

It returns only [url] tags that are not followed by another [url] tag.

minitauros 151 Junior Poster Featured Poster

You could do it in the loop that fetches your DB records. E.g.

<?php
while(...) {
    $website = $record['website'];
    $website = str_replace('$site', $site, $website);
}
minitauros 151 Junior Poster Featured Poster

Your query seems to be incorrect. You should probably not use WHERE $add_city but WHERE add_city (without the $).

Besides that, a COUNT() query might be more efficient here. E.g.:

<?php
$q = 'SELECT COUNT(add_city) AS c FROM dbAdd WHERE add_city = "' . mysql_real_escape_string($wil) . '"';
$rq = mysql_query($q);
$fetch = mysql_fetch_assoc($rq);
$count = $fetch['c'];
minitauros 151 Junior Poster Featured Poster

Just curious about your thoughts on this subject.

Example:
www.site.com/?id=1
or
www.site.com/?id=8adyfa8df614812yasdf (which is also "1", but encrypted)

What would you recommend? What do you use? Anyone with pros and/or cons on if you should encrypt your URL data?

My thoughts:
Pros (to encrypting URL data):
- Makes it harder for unwanted people to guess ID's, and thus you will have a safer application.
- Noone will have the real access keys to your data, as long as they don't know how you've encrypted the URL data.

Cons:
- Longer URL's.
- Uglier URL's.
- Need for extra security checking (encryption/decription) on each page of your application.

Considering this, I would say that an application that handles private data could benefit from encrypting URL data, as it adds just an extra bit of security, while for an application that is completely public, it would have no use encrypting URL data (obviously), as everyone has access to the application anyway.

The question that remains is: is it worth going through an extra bit of trouble to provide that extra bit of security?

minitauros 151 Junior Poster Featured Poster

Well, it could be because you're not actually specifying a value to update your record with. You could try this to see if an error is generated. If not, I guess it's your query that is using faulty data.

$RID = $_POST['RID'];
$AU = $_POST['AU'];
$TI = $_POST['TI'];
$SO = $_POST['SO'];

// In your query, $FULTEXT is probably null, or does it get defined somewhere else?
$query = "UPDATE saudi_journal SET FULTEXT = '$FULTEXT' WHERE RID = '$RID'";

echo '<p>The query that was executed, is as follows:<br>' . $query . '</p>';

mysql_query($query);
$error = mysql_error();

if($error)
    echo $error;
else
    echo "<center>Successfully Updated in DATABASE</center>";
minitauros 151 Junior Poster Featured Poster

Woops, my bad :). The first if() statement is not doing a proper check. It should be

if(!$_POST['form_name'])
minitauros 151 Junior Poster Featured Poster

I guess you should check out the fputcsv() function :).

minitauros 151 Junior Poster Featured Poster

Could you replace the last elseif() construction by the following?

elseif($_POST['form_name'] == 'update')
{
    //* The update form has been submitted. Update the database.

    // Let's see if we actually arrive at this part:
    echo '<p>Run the update...</p>';

    $RID = $_POST['RID'];
    $AU = $_POST['AU'];
    $TI = $_POST['TI'];
    $SO = $_POST['SO'];
    $query = "update saudi_journal SET FULTEXT='$FULTEXT' WHERE RID='$RID'";
    mysql_query($query);
    echo "<center>Successfully Updated in DATABASE</center>";
}

And could you add the following line BEFORE the first if() statement?

echo '<p>The following data has been submitted:</p><pre>'; print_r($_POST); echo '</pre>';

It should give you some more info on what is happening, so that you can trace why it's not working as you want it to.

minitauros 151 Junior Poster Featured Poster

Oh I see there is still a if (isset($_POST['submit'])) line in the second elseif() statement. You could remove that - the if() statement that comes a couple of lines earlier should do the work.

Are you getting any errors or is it just not updating?

You don't have to name any of the forms. I have included a hidden <input> in each form, that holds its name. That's what is being checked :).

minitauros 151 Junior Poster Featured Poster

Please read my post carefully again, as I think you might benefit from it in the future. If you have questions about it, feel free to ask! Here's an example of what you could do:

<?php
/***********************************************************************
Create database connection
*/

$db_host="localhost";
$db_name="";
$db_user="";
$db_pass="";
$conn = mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());

// Select database. Your line - mysql_select_db("$db_name"); - was okay, but you don't need to use
// quotes here :).
mysql_select_db($db_name);


/***********************************************************************
HTML output
*/
?>

<html>
<head>
    <meta name="description" content="Php Code Search & Display Record" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>

    <?php
    // Find out which form/action we need to load. I have created some
    // hidden input fields to help identifying the forms.
    if(!$_POST['search'])
    {
        //* No search query has been submitted yet. Display the search form.
        ?>

        <form name="search" method="post" action="search.php">
            <input type="hidden" name="form_name" value="search">
            <table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="0">
                <tr>
                    <td colspan="3" style="background:#0066FF; color:#FFFFFF; fontsize: 20px">
                        Search
                    </td>
                </tr>
                <tr>
                    <td width="140">Enter Search Keyword</td>
                    <td width="240"><input type="text" name="search" size="40" /></td>
                    <td width="665"><input type="submit" value="Search" /></td>
                </tr>
                <tr bgcolor="#666666" style="color:#FFFFFF">
                    <td>Record ID</td>
                    <td>Description</td>
                    <td> </td>
                </tr>
            </table>
        </form>

        <?php
    }
    elseif($_POST['form_name'] == 'search' && $_POST['search'])
    {
        //* The search form has been submitted. Display the update form(s).
        $search = $_POST["search"];
        $result = mysql_query("SELECT * FROM saudi_journal WHERE SO like '%$search%'")or die(mysql_error());

        while($row = mysql_fetch_array($result))
        {
            ?>
            <form action="search.php" method="post">
                <input type="hidden" name="form_name" value="update">
                <input type="text" name="RID" value="<?php echo $row['RID'];?>" size=6>
                Author
                <input type="text" name="author" value="<?php echo $row['AU'];?>">
                Title …
minitauros 151 Junior Poster Featured Poster

I would like to suggest a (in my opinion) cleaner solution :). This solution is as follows:

  1. Create a database file, in which you create your database connection, etc. You can include that file in every file that you need a database connection in. This way, you don't need to modify your database connection related code in every file if you once decide to change your database info. You can include a file using PHP's include(), include_once(), require() or require_once() functions. Look them up on php.net ;).

  2. I myself like to have separate files for each action/process, but in this particular situation, I guess you could have 2 forms on one page, and have the one that matches the action (e.g. update) be shown. That would go, for example, as follows (this is actually pretty much the same as vipula suggests):

    <?php
    // Include the file that manages your database connection.
    include('includes/database_connection.php');
    
    // Find out if we need to display the search form or the update form.
    if($_POST['search'])
    {
        //* A search query has been given. Display the update form.
    
        // Perform queries.
        $query = 'SELECT ...';
        // etc..
        ?>
    
        <form>
            <!-- Display your HTML stuff here... -->
        </form>
    
        <?php
    }
    else
    {
        //* A search query wasn't given. Display the search form.
    
        // Perform queries.
        $query = '';
        // etc...
        ?>
    
        <form>
            <!-- Display your HTML stuff here... -->
        </form>
    
        <?php
    }
    
minitauros 151 Junior Poster Featured Poster

I haven't done this with editable <div>s before, but usually you get a div's content by using div.innerHTML, not div.value. So changing your code to

function maths()
{
    var qt = document.getElementById("quantity1").innerHTML;
    var up = document.getElementById("unitprice1").innerHTML;
    qtup = parseFloat((qt * up)) || 0;
    document.getElementById("total1").innerHTML = qtup;
}

might work. Why are you using editable <div>s instead of just inputs? :o

minitauros 151 Junior Poster Featured Poster

You want to add all the values in the columns on the right side? What about something like:

var total = (column_1 || 0) + (column_2 || 0) ... etc

?

minitauros 151 Junior Poster Featured Poster

The problem with your code is that you are assuming that every field always has a value. However, undefined * something will always return NaN. It works the same as 0 * anything: 0 times anything is always 0. Example:

var a = undefined;
var b = 15;
var c = a * b;
console.log(c); // Outputs: NaN

var a = undefined || 0;
var b = 15;
var c = a * b;
console.log(c); // Outputs: 0

var a = undefined || 1;
var b = 15;
var c = a * b;
console.log(c); // Outputs: 15

Therefore, you could use the following code to not display NaN values, but a 0 instead of NaN if a field has not been filled in:

var amount;

function doCal() {
    var nValue = document.getElementById("noofnights").value;
    var nValue1 = document.getElementById("rate").value;
    amount = parseFloat((nValue * nValue1)) || 0;
    document.getElementById("total").value = amount;

    var nValue2 = document.getElementById("noofnights1").value;
    var nValue3 = document.getElementById("rate1").value;
    amount = parseFloat((nValue2*nValue3)) || 0;
    document.getElementById("total1").value = amount;

    var nValue4 = document.getElementById("noofnights2").value;
    var nValue5 = document.getElementById("rate2").value;
    amount = parseFloat((nValue4*nValue5)) || 0;
    document.getElementById("total2").value = amount;

    var nValue6 = document.getElementById("noofnights3").value;
    var nValue7 = document.getElementById("rate3").value;
    amount = parseFloat((nValue6*nValue7)) || 0;
    document.getElementById("total3").value = amount;

    var nValue8 = document.getElementById("noofnights4").value;
    var nValue9 = document.getElementById("rate4").value;
    amount = parseFloat((nValue8*nValue9)) || 0;
    document.getElementById("total4").value = amount;

    var nValue10 = document.getElementById("noofnights5").value;
    var nValue11 = document.getElementById("rate5").value;
    amount = parseFloat((nValue10*nValue11)) || 0;
    document.getElementById("total5").value = amount;

    var nValue12 = document.getElementById("noofnights6").value;
    var nValue13 = document.getElementById("rate6").value;
    amount = parseFloat((nValue12*nValue13)) || 0;
    document.getElementById("total6").value = amount;

    //total amount
    totalamount = …
minitauros 151 Junior Poster Featured Poster

Well your form is not being displayed in the way it should be, I think, in my browser (Firefox, 1920x1080px), but I think I get the point of it!

What about using code like this?:

var total_tax;

$('table tbody#item_rows tr.item-row').each(function()
{
    // Do we need to calculate tax for this row?
    var is_taxable = $(this).find('input.taxable').is(':checked');

    if(is_taxable)
    {
        // Get the subtotal amount that must be payed for this row.
        var subtotal_price = $(this).find('textarea[name^=costbox]').html();
        subtotal_price = parseInt(subtotal_price);

        // Calculate tax.
        var tax_percentage = 0.2;
        var tax = subtotal_price * tax_percentage;

        // Remember the total amount of tax that needs to be payed.
        total_tax += tax;
    }
});

I don't think this code will work straight away; it's just to give you an idea of what I think you could do. Am I understanding what you mean correctly now? ^^

minitauros 151 Junior Poster Featured Poster

Apparently your $row_panier['subtotal'] has no value. I guess you could start by finding out why that is =).

minitauros 151 Junior Poster Featured Poster

I don't think it will give you any more info, but have you checked the "Netstat" window of XAMPP? (It's on the right side in the control panel and might give you some more information).

Also, I have no idea if it might work, but if (in your XAMPP control panel) you click the "Config" button for your Apache server, you can open "httpd.conf". In that file, there's a line that says "Listen 80" (for me). Maybe you could change the port to something other than 80 and see if that works. I know it's not the 443 port that you're changing, while that IS the one that is causing you troubles, but I can't find where the 443 port is coming from myself, so I wouldn't know where to look to change it.

For the rest I don't think I can help you :(.

minitauros 151 Junior Poster Featured Poster

Could you add the following code right before your Total input and tell us what it says?

<?php
echo '<p>$shipping1 is now:';
var_dump($shipping1); echo '</p>';

echo '<p>$row_panier[subtotal] is now:';
var_dump($row_panier['subtotal']); echo '</p>';

echo '<p>The same stuff, number formatted is now:';
var_dump(number_format($shipping1 + $row_panier['subtotal'], 2, '.', '')); echo '</p>';
minitauros 151 Junior Poster Featured Poster

Try replacing <link rel="style" href="main.css" > with <link type="text/css" rel="stylesheet" href="main.css">, and check if main.css is in the same folder as your main.html =).

minitauros 151 Junior Poster Featured Poster

Well I'm not so fond of storing images in a database, because I don't think that's what a database is for. If you absolutely need to store images in a database I suggest you check out the base64_encode() and base64_decode() functions.

I would however still suggest saving the images in a directory on your server. You can use move_uploaded_file() to save an uploaded image (uploaded through a form) on your server.

minitauros 151 Junior Poster Featured Poster

Why are you uploading images to your database? Wouldn't it be much easier to just upload the images to a specific destination on your server, and then insert the location of that image into your database? E.g. you save your images in /uploads/images and you then save the location of a specific image in your database. For example an image called "image1.jpg" would be saved as "/uploads/images/image1.jpg" and saved as "/uploads/images/image1.jpg" in your database.

minitauros 151 Junior Poster Featured Poster

It's probably this:

You use while($row = mysql_fetch_array($result)) to fetch your data, so you cannot use $_SESSION["valid_id"] = $row->id; (an object) to access the fetched data. You should use $_SESSION["valid_id"] = $row['id']; (an array), since you are working with an array, not an object.

Indians commented: you are good at code. its working now. thanks. next i need to do upload employee image and then need to fetch. if i have any doubt i will ask you... +1
minitauros 151 Junior Poster Featured Poster

Well, for as far as I know the ? indicates the start of a query string, while & indicates the start of a new key/value pair inside that query string. E.g.:

website.com?key=value&key2=value2&this=that

The ? indicates the start, the & separates the key/value pairs.

minitauros 151 Junior Poster Featured Poster

As both posters above are saying, you can use a header to redirect the user to another page. Example:

if($row["emp_username"] == $uname && $row["emp_password"] == $pwd)
{
    // Set the header that will redirect the user to the given page
    // when this page's PHP script is done loading.
    header('Location: mainpage.php');

    // Maybe we want to save some variables in a session. In that case,
    // example:
    $_SESSION['login'] = array(
        'user_id' => $uid, // Replace by the ID of the user you're logging in.
        'username' => $uname
    );

    // (In order for the session to work, you need to have used session_start();
    // before).

    // There is no need to output this message, as the user is being
    // redirected anyway, but I'll lave it in tact for you ;).
    echo "Welcome $uname";
}
else
{
    echo "Username and Password do not match";
}

More info about session_start() on php.net: click.

Oh, and a thing to get you started on password encryption: click. Note that this tutorial is using the md5() function, of which the use is strongly unadvised (as it is seen as deprecated by almost everyone), but it will give you an idea of what password encryption is.

minitauros 151 Junior Poster Featured Poster

You could try

<?php  echo number_format($shipping1 + $row_panier['subtotal'], 2, '.', ''); ?>

instead of

    <?php echo ($shipping1 + number_format($row_panier['subtotal'], 2, '.', '')); ?>

as it makes more sense to number format an int instead of number formatting an int to a string and then adding it to another int (as pritaeas says). Of course, both variables need to be set in order to do a sum. If this doesn't work, you could try checking for the presence of a value for both variables, for example:

<?php
echo '<p>The value of $shipping1 is:<br>';
var_dump($shipping1); echo '</p>';

echo '<p>The value of $row_panier[subtotal] is:<br>';
var_dump($row_panier['subtotal']); echo '</p>';
minitauros 151 Junior Poster Featured Poster

For as far as I know, when you do something like this:

<?php echo $shipping1+number_format ($row_panier['subtotal'], 2, '.', ''); ?>

it is not just an echo that is taking place; rather the script is parsed one by one and $row_panier['subtotal'] is added to $shipping1. I think this can easily be fixed by containing your echo in parentheses, example:

<?php echo ($shipping1 + number_format($row_panier['subtotal'], 2, '.', '')); ?>
minitauros 151 Junior Poster Featured Poster

Oh that is because I seem to have made a typo in the for loop construction. It should be for(var i = 0; i < string_length; i++) instead of for(var i = 0; i <= string_length; i++). Hope this helps :)!

PS: I seem to have also made a small mistake in the other PHP script. It should be $new_number = $last_used_number + 1; instead of $new_number = $last_used_number++;.

minitauros 151 Junior Poster Featured Poster

Well with this code, and only this code, I'm getting a bunch of popups with "123" when I scroll:

$(window).scroll(function()
{
    // Let's check the scrollTop just to be sure stuff is working:
    console.log('ScrollTop: ' + $(this).scrollTop());

    if($(this).scrollTop() > 100)
    {
        alert(123);
    }
    else
    {
        alert(321);
    }
});

Have you checked your Firebug to see if any other errors are occurring that may be halting the execution of your script?

minitauros 151 Junior Poster Featured Poster

Well, it is working for me here, so then I must have falsely assumed you are working with jQuery. If you are working with jQuery, there must be something else going wrong. Did you check your Firebug for Javascript errors?

If you are NOT using jQuery, changing the randomStringToInput() function to this should work:

function randomStringToInput(clicked_element)
{
    var random_string = generateRandomString(10);
    var element = document.getElementsByName('emp')[0];
    element.value = random_string;
    clicked_element.parentNode.removeChild(clicked_element);
}
minitauros 151 Junior Poster Featured Poster

This should work:

<script>
function randomStringToInput(clicked_element)
{
    var self = $(clicked_element);
    var random_string = generateRandomString(10);
    $('input[name=emp]').val(random_string);
    self.remove();
}

function generateRandomString(string_length)
{
    var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var string = '';

    for(var i = 0; i <= string_length; i++)
    {
        var rand = Math.round(Math.random() * (characters.length - 1));
        var character = characters.substr(rand, 1);
        string = string + character;
    }

    return string;
}
</script>

<td><input type="text" name="emp" readonly="readonly" value=""></td>
<td><input type="button" value="Generate Employee Id" onclick="randomStringToInput(this)"></td>

What it does is it uses Javascript to generate a random string of X length, and then sets the value of input[name=emp] to be that random string.

minitauros 151 Junior Poster Featured Poster

Yes, except that the regex that the topic starter provided and that Atli modified in his first post will not securely check if the length of the string is really between 8 and 15 characters. Therefore you would still have to add a length check. I myself (but that's just my opinion, of course) find the code in Atli's last post the most elegant, because it is clear there which regex has what function.

minitauros 151 Junior Poster Featured Poster

Would it work if you would just retrieve the links to the files from you DB, then check what file type it is, and then display an icon for that file type instead of a preview of the file? For example for a .doc file you display a Microsoft Word icon with the file name next to it, and then when the user clicks it he is prompted with a "download file" window.

minitauros 151 Junior Poster Featured Poster

Haha :). You are right in your second post.

function doSomething($value1, $value2 = 'test')
{
    echo $value1 . $value2;
}

// Will output "hellotest"
doSomething('hello');

// Will output "hellohello"
doSomething('hello', 'hello');

However, keep in mind that it is RECOMMENDED to place predefined parameters at the end of your function. I believe you will get a notice in PHP strict if you don't. E.g.:

Don't: function doSomething($value1 = 'abc', $value2, $value3)
Do: function doSomething($value1, $value2, $value3 = 'abc')

mmcdonald commented: Helpful information :D Thank you! +3
minitauros 151 Junior Poster Featured Poster

It is indeed done like that, in general, for as far as my knowledge goes :). However, if you for example have a Registration class, that helps members register an account for your website, I wouldn't include it on pages that only registered people can see, personally, as it wouldn't have any use if it only helps non-registered members register an account.

minitauros 151 Junior Poster Featured Poster

If you put an alias on htaccess file it's like a security blanket

Could you explain this? :) And also why a website with more members could use more aliases?

@toldav:
Did you know that you can read a URI with PHP as well? Try $_SERVER['REQUEST_URI']. If you redirect all your users to an index.php page for example, you can use $_SERVER['REQUEST_URI'] to read the URI string and, for example, redirect him to another page according to the information in the URI string.

LastMitch commented: very constructive! +12
minitauros 151 Junior Poster Featured Poster

Hm yea for as far as I know the PDO::query() method returns a PDO statement (see also here). I don't know SQLite though. What works for me is this:

try
{
    //open the database
    $db = new PDO('sqlite:iSearch.sqlite');

    $statement = $db->prepare("SELECT Fname , Lname , RegoNo, Model, Color, MobNo, DeskNo, AltMobNo
        FROM Owner
        JOIN Cars ON Owner.id=Cars.Owner_id
        JOIN Contacts ON Owner.id=Contacts.Owner_id
        WHERE RegoNo LIKE :search_rego");
    $statement->bindValue(':search_rego', $search_Rego);
    $statement->execute();
    $result = $statement->fetchAll();

    // close the database connection
    $db = NULL;
}
catch(Exception $e)
{
    echo 'Exception : ' . $e->getMessage();
}

if($result)
{
    // Display results
    foreach($result as $row)
    {
        echo ' This Car Belongs to ';
        echo '<br>' . '<br>';
        echo $row['Fname'] . ' ' . $row['Lname'].'<br>';
        echo $row[ 'RegoNo'] . '<br/>';
        echo $row['Model'] . ' ' . $row['Color']. '<br>' ;
        echo '<br>';
        echo $row['MobNo'] . '<br>' ;
        echo $row['DeskNo'] . '<br>';
        echo $row['AltMobNo'] . '<br>';
    }
}
else
{ 
    // No results were found.
    echo '<p>No results were found.</p>';
}
minitauros 151 Junior Poster Featured Poster

Damn I'm such a dumbass, wasn't using htmlentities() so the <form part was recognized as HTML and therefore not printed to the screen. Sorry! This thread may be deleted, locked, etc. but I can't find a way to do so myself.

broj1 commented: Do not delete it, it might help someone :-) +9
minitauros 151 Junior Poster Featured Poster
send_email($fname,$email,$phone,$subject,$message);

You are using $fname instead of $name, that's the first thing I see that might go wrong. And where is the textarea/input in your form with the name "message"? Can it even get set? :o

minitauros 151 Junior Poster Featured Poster

For as far as I can say now: I like the new looks. Only thing is that I find the topic overview pages too busy. I think it is because there are suddenly so many images and colors because all avatars are now shown. A bit too many colors, if you ask me, but the topics themselves look great :)! Oh, and I'm typing this message right now, and underneath it are 4 options: join daniweb, log in using x, x or x, but no login using daniweb option :(.

minitauros 151 Junior Poster Featured Poster

You're welcome :)!

minitauros 151 Junior Poster Featured Poster

Well I guess it means that you have tried to initate too many connections. You should only construct your PDO object once. After it is constructed, you can work with that object the entire time (except if you need another connection, but I don't think you need that ;)?).

Maybe a better question: what is it that you are trying to make? :)

minitauros 151 Junior Poster Featured Poster

This query:

SELECT value FROM settings WHERE value = "Login Script"

seems a bit odd to me. You are selecting the value field of records of which you already know what the value field contains (namely "Login Script"). It is something like saying:

SELECT "Login Script" AS value FROM settings WHERE value = "Login Script"

Now that must seem a bit odd, does it not? ;) If you want to get the value of value of a record of which you don't know the value of value yet, you should use another field to make a comparison. For example you could use

WHERE anotherfield = "Anothervalue", E.g. WHERE id = 5 or something like that.

As for your update query, I think you have misplaced your WHERE clause (but I'm not sure if it is not allowed to place it before your SET clause). I think it should be something like:

UPDATE settings SET value = "' . $new_value . '" WHERE field = yourvalue

An example:

<?php
// Changed it to include_once() as I think you will only need this file once per page load.
include_once('include/session.php');
$db = new PDO('mysql:host=localhost;dbname=******x2_login', '******x2_login', '********');

/***********************************************************************
Settings
*/

// Do we need to fetch data, or do we need to update data?
if($_POST)
{
    // We need to update data.
    $action = 'update';
}
else
{
    // We need to fetch data.
    $action = 'fetch';
}

switch($action)
{
    case 'fetch':

        // This query may return 1 - unlimited results, as we're …
minitauros 151 Junior Poster Featured Poster

Could be that it's overheating, and if it is, you could (like caperjack said) try to clean the dust inside. You could also buy a laptop cooling platform (with vents in it) or put something underneath the back side of your laptop so that it is tilted a bit, so that the heat can flow out of your laptop more easily.

minitauros 151 Junior Poster Featured Poster

You are aware of the fact that you have

for($i = 0;$i <= count($info);$i++)
{

which loops through the info of a user, not through the array of users, and that in your echo's you are trying to access a user using the counter of the user info loop instead of the users loop? :)

I'm not sure if this will work, but I think it should:

$facename = $_SESSION["facename"];

// The file() function will just put every line in your file in a new array record. Therefore
// I've named your var $lines instead of $UserInfo.
$lines = file('datatext/users.txt', FILE_IGNORE_NEW_LINES);

echo "<table>";

// Check if $lines exists, as a foreach() loop will generate an error if it does not.
if($lines)
{
    // No special keys are present, therefore I've replaced the "$key => $value" part by just $value.
    foreach($lines as $line)
    {
        // Convert the line to a user.
        $users[] = explode(':', $line);
    }
}

// Uncomment if you would like to check the value of $users here.
// echo '<pre>'; print_r($users); echo '</pre>';

for($i = 0; $i < count($users); $i++)
{
    $user = $users[$i];

    if($user[10] == $facename)
    {
        //* Apparently we've found a user you need?

        // Echo some stuff.
        echo "<tr>";
        echo "<td> UserID </td>";
        echo "<td> : </td>";
        echo "<td> .$user[0].</td>";
        echo "</tr>";
        echo "</table>";
        echo "<tr>";
        echo "<td> Name </td>";
        echo "<td> : </td>";
        echo "<td> .$user[1].</td>";
        echo "</tr>";
        echo "</table>";
        echo "<tr>";
        echo "<td> IC </td>";
        echo "<td> : </td>";
        echo "<td> .$user[2].</td>"; …
minitauros 151 Junior Poster Featured Poster

Well yea, my suggestion should work for that, I think :). Note that if you use "JOIN", there MUST be a match in order for a row to be retrieved. If you don't mind if there is a match and want to retrieve it either way, you could use LEFT JOIN.

minitauros 151 Junior Poster Featured Poster

What happens if you replace your mysql_result() functions by a more commonly used mysql_fetch_assoc()? E.g. replace

 $Query = "SELECT * FROM database.tablename WHERE eventDay=1";
$Result = mysql_query ($Query, $Link) or die (mysql_error($Link));
//ON Debugging - code stops here resulting in Resource ID #3 - suggesting there is a problem
with the $Result. However, please check the following code to see if there are errors (if poss).
$Rows=mysql_num_rows($Result) or die (mysql_error($Rows));
$loop=0;
while ($loop<$Rows){
    //Add all variables to the output loop.
    $eventVisible=mysql_result($Result,$loop,"eventVisible");
    $eventDay=mysql_result($Result,$loop,"eventDay");
    $eventImagePath=mysql_result($Result,$loop,"eventImagePath");
    $eventTitle=mysql_result($Result,$loop,"eventTitle");
    $eventInfo=mysql_result($Result,$loop,"eventInfo");
    $expiryYear=mysql_result($Result,$loop,"expiryYear");
    $expiryMonth=mysql_result($Result,$loop,"expiryMonth");
    $expiryDay=mysql_result($Result,$loop,"expiryDay");
    //Print out the values into a table
}

by

$q = 'SELECT * FROM database.tablename WHERE eventDay=1';
$r = mysql_query($q) or exit(mysql_error());
$number_of_results = mysql_num_rows($r);

while($fetch = mysql_fetch_assoc($r))
{
    //* Looping through results

    $eventVisible = $fetch['eventVisible'];
    $eventDay = $fetch['eventDay'];
    // And so on
}