|-|x 126 Junior Poster in Training

Great! No worries, glad I could help. Can you make this thread as solved please? thx

|-|x 126 Junior Poster in Training

That is valid, and more efficient solution, but very system and configuration dependant.

Need to consider:

  • Is this a linux server and is the arp-scan command available?
  • Does PHP have shell and elevation priveleges?
  • Does the OP have root access?
|-|x 126 Junior Poster in Training

I want to say "Because...users...!"

We have told them not to, but we also told them they have to use IE since IE is the only browser that supports javascript access to the local filesystem (its an intranet) but they still use firefox.

TBH, a valid use case would be; they are working on one clients file, recieve a phone call from a different client and have to open that file but don't want to lose the work they haven't finished for the first client.

Though not currently catered for in the project spec, or system design, it would be nice if I could prevent them from screwing up their data - aka making more maintenance work for me. I'm just not sure how to go about it without using the session, unless there is some way to segregate the session variables to specific instances of the app.

|-|x 126 Junior Poster in Training

You could grab the server address (as above) and use it to determine the subnet, then perform a ping sweep for active addresses. Not super efficient but I'm not aware of any way of simply listing active addresses.

|-|x 126 Junior Poster in Training

the comparison you have should tell you the exact matches (though you are missing ;'s off the end of lines 5 & 8 (javascrip is a little forgiving if its the last line in a block).

You will have to have a nested loop to do the "correct but in wrong place" check.

Are you able to post any more code, the snippet posted above is obviously only a portion and it would be easier to help spot the issue if you can provide the whole function.

|-|x 126 Junior Poster in Training

you're missing a brace so the for loop will always return on the first iteration.

    for(index = 0; index < length; index++){
        if(array1[index] == array2[index]){
            count++
        }
    } //<-- add this brace and see if that fixes it.
    return count
}
jenny1975 commented: thank you for your help +0
|-|x 126 Junior Poster in Training

Hi all,

I have a somewhat philosophical issue I would be interested to see others opinions on. I have a site that receives several values via the querystring that are necessary for use throughout the site. By default other links internal to the site do no include these values, so to persist the data I am pulling them into session variables, which are used on subsequent pages.

I am having issues now where users are opening multiple instances of the site in different tabs of their browser. The session then becomes common accross all of these tabs, and this there have been occurrences of data contamination.

How would you approach a solution to this problem?
Are there perhaps some alternate options for persisting this data on a per-instance basis?

|-|x 126 Junior Poster in Training

Where is the dropdown getting its list from? if it is databound, you may need to force the databinding to take place first on the postback (ie: before the above event)

|-|x 126 Junior Poster in Training

I think what you are looking for is Windows authentication rather than Forms authentication.

You can set this in the web.config file as

<system.web>
    <authentication mode="Windows"/>
</system.web>

You can read some about this on MSDN - you wont need to worry about impersonation unless the website needs to access restricted resources such as server shared directories.

|-|x 126 Junior Poster in Training

are you sure you set the password correctly for this user? If it is default install, try with no password.

'root'@'localhost'

|-|x 126 Junior Poster in Training

INSERT INTO mp_creditmail (Id, message, subject, read) ('select Id from oto_members ORDER BY RAND() Limit $to;', '$messaging', '$sub', no

If that is supposed to be a subquery, the syntax is wrong - it is currently trying to insert a string value 'select Id from ...'

You are also missing a closing bracket and the VALUES keyword, see MySQL Insert Syntax (also what is the "no" supposed to be at the end?)

In order to do this as a subquery it should be as follows

INSERT INTO mp_creditmail (Id, message, subject, read) VALUES ((select Id from oto_members ORDER BY RAND() Limit 1), '$messaging', '$sub', false)

AFAIK there is no way to duplicate multiple entries in a single statement like you are trying to do. You can include multiple records (VALUES sections) in a single INSERT statement, but the looping still needs to be done in PHP and not intrinsicly in SQL.

As Mitch said, please provide any specific error messages you are getting in order to get more direct advice.

|-|x 126 Junior Poster in Training

Is there possibly some invalid character in the post values that is breaking the string when expanded at line 6? Are all 3 values present (non-null)?

|-|x 126 Junior Poster in Training

Do you actually have a mysql server installed and running? This is a separate component from php, it is included in WAMP but if you are no longer running that you may have to install a mysql server manually.

|-|x 126 Junior Poster in Training

Answer to the stupid blue lighted logo? Band aid or short strip of black electrical tape.

Or a permanent marker.

Davey, the title of this article really shows your age (or maybe mine for recognising the reference)

|-|x 126 Junior Poster in Training

when i type localhost/filrname.php.it displays an internal error message.HTTP Error 404

Probably indicates a configration problem with WAMP as it seems to not be finding the page/file. Did you configure Apache to run on port 80? Does your machine also run an IIS or other service that could be conflicting with apache?

When you open the file (even in a browser) directly from the filesystem - ie: by double clicking the file in windows explorer - it isn't being run through apache or the php engine and the php code wont be processed. A browser will simply parse it as text/html.

|-|x 126 Junior Poster in Training

As far as I can tell (from a quick glance) your MIME encoding seems OK

However, you need to specify the image as inline, or it will show up as an attachment.

Content-Disposition: inline; filename=logo.gif

You also need to specify an ID for reference within the email content. (this is arbitrary but I find it useful to use the filename for clarity sake)

Content-ID: logo.gif

Then in the message body the image source references the content ID of the attached MIME segment.

<img src="cid:logo.gif" />

I think that is all you will need to modify.

edit: additional note You may want to use a longer string for your boundary, typically a randomly denerated md5 hash or similar is used, though again strictly speaking this is arbitrary (you just don't want it to be something that may occur accidentally within message content.)

Also, having your $bound variable including the line breaks will mean that your MIME boundary definition Content-Type: multipart/mixed; boundary=\"$bound_text\"" will push the closing quote mark onto the next line - might be advisable to add the line breaks separately.

|-|x 126 Junior Poster in Training

Just to follow up on something, and correct me if I'm wrong, but doesn't the IF block only work in the actual HTML page code and not in a CSS file?

I recall usually seeing it to optionally include a separate stylesheet like so

<!--[if IE 6]-->
<link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->

If I am correct, then depending on how the browser handles the <!----> tags it will either break the style sheet at that point, or just ignore the condition and apply the styles inside regardless.

TonyG, can you confirm? (just for interest).

cheers

|-|x 126 Junior Poster in Training

I fixed it manually by inserting a div at the point I mentioned before. But effecting the appropriate styling to container div should also do it.

Update - Confirmed, container doesn't seem to be loading the styles (firefox & chrome checked). Maybe change the name to see if it's a conflict with jQuery as TonyG suggests, would appear to be the case at this point.

|-|x 126 Junior Poster in Training

It's appearing left aligned because tou have float:left on the divs primary, content and secondary. If you wrap these 3 divs in another div with margin:0 auto as TonyG said, it should center the lot.
Edit You also need to specify a width on that wrapper div or it will default to 100% and the centering effect will be moot.

|-|x 126 Junior Poster in Training

You have no closing tag for the figcaption which may cause layout problems

<figure>
<div align=\"center\">
<a href=\"\"><img src=\"images/" . $row['product_img'] . ".png\" alt=\"" . $row['alt_desc'] . "\"></a>
<figcaption><p>" . $row['product_name'] . "<br>
<b>£" . $row['product_price'] . "</b>
</p></div></figure>

|-|x 126 Junior Poster in Training

Try setting padding: 0 on your UL element.

It's common practice to use a "reset" css (either one downloaded from the net or a custom one) to set some global initialisation values such as zero padding margin and border for all elements. This may be something you could look into as it overrides the default values that some elements carry which I think is the source of your issue.

|-|x 126 Junior Poster in Training

Why is your foreign key also your primary key for table Book?
What happens if a publisher has more than one book?

Typically the table structure you would see for this relationship is like this:

book_id (PK,auto_increment)
publicher_code (FK)
title

book_id will generate automatically when the record is inserted
publisher_code must be inserted manually and must reference a valid existing record in publisher table

|-|x 126 Junior Poster in Training

Sorry couldn't find the initial example I used a couple months ago, was sure they had it in their official sample code somewhere but it goes something like this.

StringReader stringReader = new StringReader(htmlText.ToString());
Document doc = new Document(PageSize.A4);
List<iTextSharp.text.IElement> elements = 
    iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(stringReader, null);
doc.Open();
foreach (object item in elements)
{
    doc.Add((IElement)item);
}
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Close();

Codeproject and stackoverflow both have a bunch of posts covering this and other iText topics.
There is also the XMLParser classes (an update of the old HTMLparser class from iText) which is able to parse HTML5 to PDF but I haven't used this.

Also, here are some good tutorials I bookmarked for creating pdfs with iTextSharp.

|-|x 126 Junior Poster in Training

I actually can't see anything wrong with the loop, as such.

JorgeM has a good point, but since you aren't resetting XExists it should maintain its state through the remainder of the iterations.

The comparison may be an issue as ggamble suggests, but afaik C# will throw an exception if it can't do an implicit type conversion during the comparison anyway.

Can you break your code on the foreach and check the contents of ddlX.Items to ensure it has all the items you expect? If this list is being created dynamically the processing may be occuring prior to the list being re-populated after the postback.

Otherwise it is possible the cause of the issue is outside the code snippet provided here.

|-|x 126 Junior Poster in Training

Although this appears to be a zombie thread, I'm going to recommend iTextSharp which is free open source part of the iTextPdf library project.

If you look in their docs they have sample code to convert from HTML as well as building a PDF from scratch.

|-|x 126 Junior Poster in Training

It doesn't really matter so long as it's inside your form tags, but for ease of reading I'd put it just below where you are displaying the name at line 57.

(Don't forget that you will need to do the same type of hidden input for fname as well).

|-|x 126 Junior Poster in Training

This is really pretty vague, is there any more information you can post?

  • What version of Windows are you running?
  • Has there been any changes (hardware, software or configuration) to your pc recently?
  • did you notice anything strange just prior to this occurrance - running slow, error messages, something not working etc.?
  • do you have a recovery disk / backup that you could restore the system from?

If no warning signs were noticed it could be a corrupted hard disk sector or bootloader. You could try running a disk repair/maintenance program like Spinrite and see if it fixes the problem. (Of course it could also be some other issue, just a suggestion to try.)

|-|x 126 Junior Poster in Training

The Ubuntu live CD will allow you to do a side by side installation (dual boot), but I believe you need to have a separate drive or partition in order to maintain both OS.

|-|x 126 Junior Poster in Training

I personally don't see anything wrong with what you have there. It's difficult for students with relatively little commercial experience to demonstrate their applicable skills, so I wouldn't worry about having typing and such things just now - in 5 or 10 years when you have a few more jobs to list I would expect to see more technical skills and things like typing to be generally implied. Just be ready to discuss and answer questions about anything included on your resume, for instance how various skills may aid you in fullfilling the requirements of the role.

I don't see any server side or database experience listed, given that the job description would seem to be working within a PHP based CMS I would assume they will look for these skills - if you have done any related course work I recommend including it. Also, if you have done any group project work briefly mention your involvement and the outcomes.

|-|x 126 Junior Poster in Training
|-|x 126 Junior Poster in Training

Try putting them in hidden fields

<input type="hidden" name="lname" value="<?php echo $row['lname'] ?>" />
|-|x 126 Junior Poster in Training

fname and lname are being fetched from my DB

Thats fine, I can see that. But at line 19-20 in the save code you are still trying to access them from the POST variable

$value1 = $_POST["lname"];
$value2 = $_POST["fname"];

You will need to either fetch the employee record again at this point, or include this data in the form post (perhaps in hidden fields).

The other thing to check is that your form is definitely submitting to the correct address since you are using a separate file for processing. (Not that I can see anything wrong, but we can't see your file system structure here)

|-|x 126 Junior Poster in Training

Just after a quick look through your page code, I can't see any inputs for fname or lname, which will cause those POST variables to fail.

Are you getting any specific error messages from PHP?

|-|x 126 Junior Poster in Training

OK. So a little clarification on linked lists, because I can see where you are having trouble.

You have the list declaration inside the loop, which means each time you input for a new student you are actually creating a whole new list (not just adding to the existing list). In the same way, your output needs to be outside the loop in order to output once for the entire list and not for each item during the input process.

So logically (in pseudocode) it would look like this.

instantiate list
loop through students
    collect user input for each student
    add student to list
end loop
ouput list

Hopefully that makes sense, and should be enough to help modify your code so that it works - you're really close.

|-|x 126 Junior Poster in Training

It looks like you aren't actually calling name.add() anywhere in the main function. Only reading the input into local variables.

I think line 21 StudentList name = new StudentList(); should be outside the loop, and this is the spot where you need to call the add() function.

|-|x 126 Junior Poster in Training

To nest the if() functions, simply place an aditional one inside the true or false return sections like so if(condition,true_1,if(condition2,true_2,false_both)) This would be useful if you had more than two unit types, for example:

if(unit='cm',qty/100,if(unit='mm',qty/1000,qty))

would convert both cm and mm to m. If you have more than this you would be better to use a CASE statement. Have a read of the MySQL docs for more info on both IF and CASE.

In order to pull the units from a different table you would need to join that table based on some key. (This is purely speculative as I don't know what your data structure is.)

SELECT 
    table.item, 
    sum(if(unittable.unit='cm',table.qty/100,table.qty)) qty, 
    'm' unit 
FROM table
LEFT JOIN unittable ON unittable.id = table.unit_id
GROUP BY table.item

However for this purpose you could just as easily use the presumed unit_id value in the IF condition rather than joining as it would be simpler and faster.
Check the MySQL docs for more on joins.

|-|x 126 Junior Poster in Training

You will need to populate the tbl_cat first. (I am going to assume your id fields for both tables are auto_increment)

INSERT INTO tbl_cat (category) VALUES ('Accessories');

The easiest way to do the child table insertions is to manually check the id generated in the previous table.

SELECT * FROM tbl_cat;
+----+-------------+
| id | category    |
+------------------+
| 1  | Accessories |
+------------------+

You can then use this id in the foreign key field for your child table insert like so...

INSERT INTO tbl_subcat (catid,subcat) VALUES (1,'some subcat');
INSERT INTO tbl_subcat (catid,subcat) VALUES (1,'another subcat');
|-|x 126 Junior Poster in Training

You may be able to do an open-behind type behaviour with javascript but I don't think there is a way to do it in the anchor tag itself.

|-|x 126 Junior Poster in Training

add target="_blank" to the a tag

|-|x 126 Junior Poster in Training

the sum() function simply calculates the total for the group of whatever field you give it, so if you just said sum(qty) you would end up with 101 for rod1.

The if function is where we do the conversion, and it operates just like any typical if statement: if(condition,true_part,false_part) so we are saying if the unit is 'cm' return qty/100 (convert to m) else just return qty. You could nest these, or use a case statement if you had more than two unit types.

The qty at the end is the alias for the column, otherwise the column header would show the formula - this is the same as saying sum(..) as qty (the as is optional).

Since we are grouping we can't just select the unit column as it wont necessarily pull the correct row, and since we are converting all units to m, we can hard code this value in the column. Therefore 'm' unit is simply returning the hard coded string 'm' for all rows as a column named unit

Hope that explains everything.

|-|x 126 Junior Poster in Training

You have to use grouping, and I assume from what it looks like that you are converting the units from cm to m.

try something like this...

SELECT 
    item, 
    sum(if(unit='cm',qty/100,qty)) qty, 
    'm' unit 
FROM tablename
GROUP BY item
|-|x 126 Junior Poster in Training

Do you want to know how to add the actual foreign key constraint? or how to manage the data insertion?

|-|x 126 Junior Poster in Training

are you talking about nesting one gridview inside another? or having two linked datagridview controls side by side on the page?

|-|x 126 Junior Poster in Training

As a general rule of thumb, install older versions before newer versions of the same software. Install software in heirarchical order, apps before plugins etc. (eg: VS before Crystal).

In your list above I would probably install SQL server first, as it is likely to be the heaviest. I have also had trouble in the past getting different versions of SQLsvr to play nicely together, theoretically they should be fine, but just be careful about the instance configurations.

Hope that helps.

|-|x 126 Junior Poster in Training

You will need to check the POST variable to see if a user has been selected, then make an additional call to the database to fetch the related data.

I have also added a javascript call to automatically post the form when the dropdown is selected.

It will probably be easier if you move your <select> tags inside the php code. Then you will be able to print out the other data outside of the dropdown, as per below example.

<form id="userform" method="post" action="drop.php">

    <?php

        $mysqlserver="localhost";
        $mysqlusername="root";
        $mysqlpassword="";
        $link=mysql_connect(localhost, $mysqlusername, $mysqlpassword) or die ("Error connecting to mysql server: ".mysql_error());
        $dbname = 'members';
        mysql_select_db($dbname, $link) or die ("Error selecting specified database on mysql server: ".mysql_error());
        $myquery="SELECT username FROM members";
        $myresult=mysql_query($myquery) or die ("Query to get data from members failed: ".mysql_error());

        echo '<select id="user" name="user" onchange="document.forms[\'userform\'].submit();">';

        while ($row=mysql_fetch_array($myresult)) {
        $user=$row[username];         // NOTE: username should be in quotes here.
            echo "<option>
                $user
            </option>";
        }

        echo '</select>';

        if (isset($_POST['user'])) {
            $r = mysql_query("SELECT password, email FROM members WHERE username='".$_POST['user']."'") or die ("Unable to get user details: ".mysql_error());
            while ($row=mysql_fetch_array($r)) { // there should only ever be 1 result
                // display the data however you want, add some HTML tags to format nicely.
                echo $row['password'];
                echo $row['email'];
            }
        }

    ?>
</form>

Please note that the above code is not tested, but should give you an idea of how to proceed.

Also, it is bad practice to use a POST variable directly in a query string (as I have done here) without parsing it for …

|-|x 126 Junior Poster in Training

these are exactly the kind of computers being put to use by the bad guys in decoding those stolen databases of encrypted (salted but not hashed) usernames and passwords that you read about in the news.

.

Sorry, that's absolutely not how encryption works. Salting only means anything in the context of hashing.

I think he meant Hashed but not Salted, as this was the case with the LinkedIn incident.

happygeek commented: thanks for spotting that stupid typo which I missed when editing +11
|-|x 126 Junior Poster in Training

You should be able to interact with multiple databases without needing multiple connections open from php. Check out the mysql use command.

You can also reference the databases directly in your query.

SELECT * FROM db1.tableA;
SELECT * FROM db2.tableA;
|-|x 126 Junior Poster in Training

sorry mate, still not sure I understand your problem correctly.

so the dropdown determines the column you want to sum? if that is the case you need to build your query dynamically.

$sql = 'SELECT SUM('.$_POST['select'].') FROM table';
|-|x 126 Junior Poster in Training

Actually, it could be that your server is not configured to process PHP properly. Can you set up a basic test script and check your output as per this example?

|-|x 126 Junior Poster in Training

regprocess.php, line 2: make sure you have a space between the include command and the filename.

include"config.php";

Also, regprocess.php doesn't produce any output. Although, I don't believe this should cause the code to be printed, I suggest adding some print statements, a redirect, or something.