Many thanks @cereal problem solved. Cheers.

Hi diafol,

Yes that's correct i only ever get

file empty so gonna write data to file.

i added the code you gave before line 12 and it outputs

The file size is actually 0 bytes.

yet in the file i have

1487071245 ; 582

Cheers.

Hi,

I wrote some code below, at the moment i'm testing so there's no database queries in the code but before i do that i'm hoping someone can help. The code below where it says if(filesize($filename) != 0) always goes to else even though the file is not 0 bytes and has 16 bytes of data in there.

I think it's easier to show my code (could be other errors in there but i'm checking each error as i go along, dealing with them 1 by 1). I get no php errors or anything so can only assume it's my if statement.

$filename = 'memberlist.txt';
$file_directory = dirname($filename);
$fopen = fopen($filename, 'w+');

// check is file exists and is writable
if(file_exists($filename) && is_writable($file_directory)){

    // clear statcache else filesize could be incorrect
    clearstatcache();

    // check if file contains any data
    if(filesize($filename) != 0){ // also tried !==

        // read file into an array
        $fread = file($filename);

        // get current time
        $current_time = time();

        foreach($fread as $read){
            $var   = explode(';', $read);
            $oldtime  = $var[0];
            $member_count = $var[1];
        }
            if($current_time - $oldtime >= 86400){
                // 24 hours or more so we query db and write new member count to file
                echo 'more than 24 hours has passed'; // for testing

            } else {
                // less than 24 hours so don't query db just read member count from file
                echo 'less than 24 hours has passed'; // for testing
            }
    } else {
        // else file is empty so we add data
        $current_time = ...

Solved.

For anyone having similar issues it needs to read like the below.

UPDATE 
    users_profiles
INNER JOIN 
    users
ON
    users.user_uid = users_profiles.user_uid
SET 
    users_profiles.user_fname = 'John', 
    users_profiles.user_lname = 'Doe', 
    users_profiles.user_gender = 'male'
WHERE
    users.user_login = 'johndoe'
AND
    users.user_uid = '11'

Cheers.

will play with it a bit more. the syntax error i get is confusing i admit, not sure why it displays it like that.

If i press simulate query instead of go in phpmyadmin i get:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON users.user_uid, .user_uid FROM users_profiles WHERE users.user_login ' at line 7

Thanks for the reply. I already tried with and without the USING (user_uid) and still get error. It seems to be something to do with the INNER JOIN by going from error below.

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN
    users
ON
    users.user_uid = users_profiles.user_uid
WHERE
    user' at line 7 

Cheers

Hi,

Not done any programming for a few years so am somewhat rusty again.

I have two tables users table and users_profiles table. I want to update users_profiles table on the condition that user_uid matches on both tables (users.user_uid and users_profiles.user_uid) and where users.user_login = 'johndoe' and users.user_uid = '11'.

It wil be executed in a php script, so johndoe would actually be users username (whatever is stored in session and same for users_uid. For simplicitity i added dummy data.

I run the query in phpmyadmin and get syntax error near INNER JOIN. I just cannot figure out what i'm doing wrong (probably wrote it entirely wrong) and have spent few hours trying to work it out without success.

Heres my sql query.

UPDATE 
    users_profiles
SET 
    users_profiles.user_fname = 'John', 
    users_profiles.user_lname = 'Doe', 
    users_profiles.user_gender = 'male'
INNER JOIN 
    users USING (user_uid)
ON
    users.user_uid = users_profiles.user_uid
WHERE
    users.user_login = 'johndoe'
AND
    users.user_uid = '11'

any help much appreciated.

Cheers.

UPDATE:

I am adding the error information i am getting when running query via phpmyadmin. I can only assume i am doing the sql query all wrong.

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN
    users
ON
    users.user_uid = users_profiles.user_uid
WHERE
    user' at line 7

I figured it.

They had register_globabls on so i asked them to give me a copy of the php.ini file so i can edit and change things myself.

Can you beleive they told me that they cannot turn it off for me. Reason why is i now have to place the php.ini file in every folder etc, plus register_globals should be off by default anyway due to the security issues that come with it.

Thanks

mmmm,

I just switched the PHP version from 5 to 4 in control panel and it now works fine althou the session data is still a random string.

Thing is i use php 5 on old web host. I can only think there must be a configuration setting in the php.ini file which i don't have access to.

But if anyone could explain or know any reason that would be great as i rather know before trying another webhost. I want to stick to PHP 5 not 4.

Thankfully i had a free 14 day trial which started yesterday.

There support does not seem to have a clue, all they said was ask another developer :O

Hi,

I just started a free trial with a new webhost as my current one is useless.

I have always had my website working on the old webhost fine.

I have a folder called sessions outside the public_html folder so it cannot be accessed in a browser and not accessed by anyone else as i am on a shared host.

With my previous host everytime i logged in to my own website i could edit the session file and see all the users data in there. For some reason on my new webhost when i login and try and view the session data in the session file all i see is one very long random string.

Problem is i don't know why this is happening, i see no user data in there just a long random string. It is causing my website problems as for example, when i login the main control panel page shows my name which is stored in the session which is good but when i go to edit profile page no data is being shown in the form boxes from the session, just blank jet on my old host it shows data like it should.

another problem is the view profile webpage is also repeating the user data, again strange as it is coming from session yet for example instead of showing the username once it is showing it multiple times (repeating iteself).

As i say my site has never gave me problems on old webhost. ...

Just an update,

I used some code i found online to setup a redirect in .htaccess.

So what happens now is user with that IP will be redirected to a secret/hidden non indexed page to tell them to contact me as i beleive they maybe having problems with site etc, i kept it polite incase they are genuine. I also placed on the page they are redirected to that if IP does not match the redirected one that is having problems to redirect to homepage.

So far so good :)

So thanks for your help.

Thanks
GUK

[QUOTE=jmo;1169270]Is the download freely available to registered members, and registration is free - i.e. it's not a file that requires payment?

Assuming it's freely available...

The only hacking effort I can think of is a rather weak DoS attack, asking your server to download a potentially huge file repeatedly. I would only suspect malicious intent if the timestamps on the errors indicate some type of automated process.

Could it be that the user can't complete the download on his end, so is just repeating the process? If I were in your shoes, I might put a trap page for the IP range 117.98, and push them to a temporary page that recommends they send an email if they're having difficulty with the download.[/QUOTE]

hi,

Thanks for your reply.

Registration is free so is the download, my entire website is free.

The file is only a few KB's in size.

I will take your suggestion on board about page trap sounds good idea, will take a look around to see how i could implement something like this.

Myself and everyone else has no problems accessing the file and page and i only get errors in error log and receive email from those two IP's

Thanks
GUK

Hi,

I wonder if someone can advise.

My website has been working great ever since i first launched it.

I made a script months ago to notify me of errors like 404, 500 etc and so on and it works perfectly.

Two days ago someone accessed my website and they kept trying to access the same link constantly. This link is to download a file and is only available to members only and if i or anyone else access we never get errors i also never get any errors sent to me via email or in my cpanel error log file. The error log in my cpanel and the error i get via email shows the same ip and it only ever happens to this particular IP. This went on for several hours so i banned the IP.

I unbanned the IP that night and it stopped. but today the same IP apart from the last three digits was different must be doing something as i am having the errors again.

I am getting dozens of emails every few minutes.

Another thing i done a search on my members and notice two accounts one was registered today both have the same IP apart from the last 3 digits. The first account i suspended back two days ago until they contact me but the same IP apart from last 3 digits was logged when someone was registering today. Suspiciously they have the same first name and username is similar to last ...

Thanks for replying. I will rename my css and js file to .php and do what you said i know what ob_start() and flush is but did not think of it like that.

Thanks for all the replies.

Hi hope it ok to reply as not had any others yet, anyone else recommend best way or the way they do it?

Thanks

Hi hope it ok to reply as not had any others yet, anyone else recommend best way or the way they do it?

Thanks

Hi,

It doesn't really answer my question i don't think, my site design which is split in two files is fine as it is as i want same layout navigation links etc the same on all pages hence why it is only in two parts.

My question is more wheter i should put all includes in the head tags or just include the scripts within the page that needs it althou like you said it should really be in an order, as loading javascript after the head section etc has been processed suppose to slow things down to what i have been reading online.

Once i get a few more responces from the community and if they agree i should put them all in the head section i can simply just put all javascript in one file and compress to reduce size and HTTP REQUESTS. I can simply keep an uncompressed version and if and when i ever need to edit the javascript i can just compress again after editing. Same goes for other files like my function and global file, i could just make one file and put all code in the one file to reduce HTTP REQUESTS as much as possible. Things like website address, name and other $variables are in my global file so if i ever change host, websiteaddress etc i only have to edit one page.

Thanks

Hi,

I wanted to ask professional members who has built websites in the past wheter you include all your include files in the section of your site. I split my design in two header-inc.php and footer-inc.php, obviously the section will be in header-inc.php.

Reason is most of my pages require different scripts. Currently i just place for example the javscript in the file that requires it but it makes my code look very messy and hard to navigate/read or i just put an include in the file that requires the script.

I wanted to know as if i had let say 6-8 includes in my head section will it slow down my site, some of the includes won't be required on everypage so in a sence it seems silly to have an include on a page that won't requrie that specific included file althou i think it is best practice... but i thought if i add them all in the tags it would save me having to put the code within the actual page or use an include in whatever file etc.

Thansk for any responce. Just want to clean up my code and organise things more now i have learnt allot more and wanted to know how you do it and/or what is the best way/best practice.

Thanks.

Can you tell me how you do it?

I think NetBeans is great. I tried aptana and it is ok but something quite does not do it for me. I would recommend you try NetBeans. I have tried i think everyone or nearly everyone out there and i have not really found one that suits.

Problem is i am used to the color coding in Dreamweaver CS4 and in all other programs it obviously different. I know you can change the color yourself but i can never get it the same as dreamweaver.

I did see a addon for NetBeans to make code color same as Dreamweaver but i cannot find it again now. Anyone got it or know where i can find it please reply. :(

Thanks

[QUOTE=JRM;1098441]Ok ! Great.
A bit more tenacity paid off.
Something simple was clogging the works as usual.
In this case...A DOT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I wonder if there is a statistic about what percentage of programmers end up in the loony bin?[/QUOTE]

I will be in one myself soon lol at that rate today.

Very rare i have problems and when i do i come here and or ask my friend.

i will be switching from Dreamweaver thou, it's no help personally i dont think to a programmer. When being realtively new i think it's good to have a program that neatens the code as you go along, provide code hints and warns of an error etc it makes the world of difference even to an experienced programmer, plus things like macros etc, all about efficentcie i think and better work flow.

Thanks everyone thou as usual.

I know lol. All day i could have been programming other parts i been wanting to do today and all that for a dot lol.

One measley .

But thanks, you have been such a fantastic support to me.

Thanks as always.

OMFG. I FIXED IT :):D

Where i have WHILE loop in original script i have

[b]$results_display_2 = [/b]

Basically i assigned the results and table in that variable to display further down the page after the form althou i am not sure why that wont work it seems to have fixed it by adding haveing .= instead of just =

YIPPY. Once again thanks for everything.

Maybe you could explain Alti if you understand what i dont wrong.

Thanks as always.

[QUOTE=Atli;1098386]Ohhh /facepalm
I left a couple of errors in my last code :icon_redface:

Try this one. I've already tested it locally so it should work.
[code=php]
<?php
ini_set('display_errors', true);
error_reporting(E_ALL + E_NOTICE);

$dbLink = mysql_connect('localhost', 'user', 'pwd') or die(mysql_error());
mysql_select_db('dbName', $dbLink) or die(mysql_error());

$sql = 'SELECT * FROM userinformation';
$result = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result))
{
echo "

", print_r($row, true), "
";
}
}
else {
echo "Query succeeded returned nothing...";
}

mysql_close();
?>
[/code][/QUOTE]

Hi Alti,

Once again thanks for being so kind to help.

It is showing all users :) with code given above. I also commented out database stuff and added the sql_con(); and it showed all users to :) . My original code i put in netbeans and it says it's fine. I use dreamweaver currently but i wont be using again as i am not kean on it not ideal for programming.

I then used the WHERE clause and great it showed 4 results as it should have done.

So i guess something wrong with my original code althou netbeans says there is no errors, warnings etc and no errors on search and with error reporting turned on. I have also checked the code by eye and i dont spot anything wrong althou i am not an expert as only been learning for several months.

mmm, i will play with my code althou it the same as on forum and to make sure forum has changed it i also ...

Was also meant to say that my original first post with search box still works, i mean obviously it only displays one result hence this topic being made but i mean it does give me a result. I have had a bad spell put up on me i think.

Hi Alti,

I am suprised you replied i thought you probably got fed up.

Ok, i tried your code again blank page, only thing outputed is the

 tags in view source.

I then added the code below to turn on error reporting:

[CODE]ini_set('display_errors', true);
error_reporting(E_ALL + E_NOTICE);[/CODE]

Again no errors or anything just blank with with pre tags in view source.
Again i checked my admin and was able to view/update/edit etc like normal and login to my normal account and update profile etc so database must be fine i am sure.

I am completely and utterly confused. This is why i thought cannot be database as it is displaying my members list in admin and like the rest i said above. I also tried there where clause just to see, worth a try and nothing again.

I don't get it, maybe i got some magic code in my other scripts that i am not aware of lol. Oh dear it ok to laugh lol but it just uses up time and causes problems i could do without lol.

I also checked database details in cpanel and phpmyadmin over and over and all database information is correct. Althou i know that as i can do everything i want on site, but again checked incase.

Thanks again.

[B]UPDATE:[/B]

I just tested on local machine with xampp latest version as i use that for testing locally, the same database is in phpmyadmin on local computer again nothing. :-O

Hi Alti,

Once again thanks for explaining the htmlspecialchars.

Again still nothing.

[QUOTE]Do you have error reporting turned on?[/QUOTE]

Error reporting is turned off on host i use and i have no control on it so i used the code you gave and no errors.

[QUOTE]And don't you have to include the sql_con function into that code before you can use it? Or is that a part of some global include?[/QUOTE]

Also the slq_con(); is used everywhere on my site and works great including my admin where i have view/edit/delete user/view member list etc, so not that but to test i created a db_connect.php file and again no luck.

The sql_con(); function was included in that code you put in last post.

[QUOTE]My first guess would be that there is something wrong with the database connection itself. Perhaps you are connecting to the wrong database, or there is some error in the connection that is being suppressed.
That would probably be in your sql_con() function. If you post that here, maybe we could spot the problem in there.[/QUOTE]

I have been using my admin all day editing/updating stuff without problems using the sql_con(); function and it is definately correct database. I thought maybe something wrong with database but obviously there isn't otherwise i would not be able to view/edit/update database via my admin etc and/or play with my site profile etc.

[QUOTE]My second guess would be that there is some character encoding error. You may want to check which encoding ...

[QUOTE=szkoda;1098256]
I've managed to get the drop down list to populate (a misplaced ';') but the textboxes still arnt being populated. Do you know what could be wrong with the mySQL?[/QUOTE]

Have you posted in wrong thread as this is the wrong one you posted in. If you have a problem make a topic for yourself unless you replied to wrong one.

[QUOTE=almostbob;1098252][code=php]while($row = mysql_fetch_array($query)) { /php / }[/code]Not sure but is there usually a $row++ at the ned of this section to get the next row[/QUOTE]

Hi,

Not needed as i got [b]*[/b] in query to get everyything from row that have username that is Like [b]%ja%[/b] and mysql_fetch_array will return the entire row(s) and store in an array if it matches the search term [b]ja[/b] which for some reason it isn't althou in phpmyadmin same query does give 4 results. Plus i used blank page with and without a simple text box to test and nothing.

Thanks.

Hi Alti,

Thanks for the reply. I opened a new document and i get no results. I adjusted the code you gave obviously where needed and get nothing.

Also what do you mean by the htmlspecialchars part?.

I have removed it as your rite, silly me for not thinking. But i add htmlspecialchars to all form elements that i know won't contain the predefined characters as set by php, most times i use regex as i prefer it for validation.

For example usernames cannot contain the below which htmlspecial chars converts due to my regex pattern on usernames hence why i added it as i know none of those characters below will be in the username row in database, althou i did add more to my original query so genuinely forgot to remove it.

& (ampersand) becomes &amp;
" (double quote) becomes &quot;
' (single quote) becomes '
< (less than) becomes &lt;
> (greater than) becomes &gt;

Not sure why i am not getting any results.

First i done it this way in blank page with no results:
[CODE]
<?php
sql_con()or die(mysql_error()); // db connect
$sql = mysql_query("SELECT * FROM userinformation WHERE username LIKE '%ja%'") or die(mysql_error());
while ($row = mysql_fetch_array($sql));
{
echo "

".$row['username']."
";
}
?>[/CODE]

Then i tried this way:

[CODE]<?php
sql_con() or die(mysql_error()); // db connect
$sql = "SELECT * FROM userinformation WHERE username LIKE '%ja%' ";
$query = mysql_query($sql);
echo "

$query
";
?>[/CODE]

Again no results. If you look you will see i added [b]ja[/b] as the ...

Hi,

Thanks for the reply. I not had problems with queries etc on any other part of my admin i have built. Here is my full code.

Thanks.

[CODE]<?php
include ("".$_SERVER['DOCUMENT_ROOT']."/admin/global.php"); // include global file
require_once("".$_SERVER['DOCUMENT_ROOT']."/admin/session.php"); // include session file
admin_error(); // check if user is logged in
$title = " Member Search";
include ("".$_SERVER['DOCUMENT_ROOT']."/admin/top.inc"); // include top.inc
?>

<?php

if (isset($_POST['submit']))
{   
    // Collect data from input box
    $search = htmlspecialchars(strip_tags(stripslashes(mysql_real_escape_string($_POST['search']))));   

    // Check / Validate data
    if(empty($search))
    {
        $search_empty .= '<p><span class="error">In order to perform a search you need to enter a search query.</span></p><br />';  
        $err++;
    }

    // If validation is ok continue
    if ($err == 0) 
    {
        // db connect
        sql_con();

        // query db 
        $query = mysql_query("SELECT * FROM `userinformation` WHERE `username` LIKE '%$search%' OR `email` LIKE '%$search%' OR
                             `id` LIKE '%$search%' OR `first_name` LIKE '%$search%' OR `last_name` LIKE '%$search%' ORDER BY id ASC") or die(mysql_error());

            if (mysql_num_rows($query) > 0)
            {
                ?>

                <table width="100%" cellspacing="5" cellpadding="4">
                    <tr>
                        <th nowrap="nowrap" class="tablebg">User Details</th>
                        <th nowrap="nowrap" class="tablebg">Options</th>  
                    </tr>

            <?php
            while($row = mysql_fetch_array($query))
            {
                $results_display_1 = '<p>You searched for <b>' . $search . '</b> and below are your results. <br /><br />';
                $results_display_2 = 
                '<tr>
                <th nowrap="nowrap" align="left" style="background-color:#F1F1F1; font-size:10px; font-weight:normal; line-height:15px;">
                <b>ID:</b> ' . $row['id'] . '<br />
                <b>Status:</b> ' . $row['status'] . '<br />
                <b>Username:</b> ' . $row['username'] . '<br />
                <b>Full Name:</b> ' . $row['first_name'] . ' ' . $row['last_name'] . '<br />
                <b>Email Adddress:</b> ' . $row['email'] . ' &nbsp;<a href="email.php?emailuser='.$row['email'].'&username='.$row['username'].'">[email user]</a><br />
                <b>Registered on:</b> ' . $row['date_time'] ...

Hello,

I was going to post the full script but don't think it will ne needed.

Basically i have this query:

[CODE]// query db
$query = mysql_query("SELECT * FROM userinformation WHERE username LIKE '%$search%' OR email LIKE '%$search%' OR
id LIKE '%$search%' OR first_name LIKE '%$search%' OR last_name LIKE '%$search%' ORDER BY id ASC") or die(mysql_error());[/CODE]

Now when i do a search for example [b]ja[/b] in phpmyadmin it gives me 4 results as 4 people have a username that begins with [b]ja[/b] yet my query on my search form above only brings back one result.

The query in phpmyadmin goes like:
[CODE]
SELECT *
FROM userinformation
WHERE username LIKE '%ja%' [/CODE]

I have tried numerous ways with no luck. apart from the additional OR the query is the same yet it only gives on result. I tried removing the or(s) althou that suppose to obviously give back more results based on the LIKE in the query.

Does anyone know what could be causing it to only give one result?

Any help much appreciated as always.

Thanks.