Nyight 10

Misread but cannot (or don't know how to) delete, apologies.

Nyight 10

Nyight 10

Display_errors can only be set to 0 (off) or 1 (on), E_ALL is for the setting error_reporting.

Also some hosts disable ini_set() for security purposes, have you tried placing a php.ini file, with the single line of [b]display_errors = 1[/b] in the same directory of the file that's not working properly?


Nyight 10

Exclusion from rand is usually not a good idea as it makes things incredibly difficult rather fast (at least from my own experiences).

In your file thing above, loop through each file and add each one to an array:
// PSEUDO CODE!!!!!!!!!!!!!!!!!!
foreach($file found in $directory){
$array[] = file;

Nyight 10

Fyi P0lT10n, he could have a field with the name of submit that he's using...

Nyight 10

[QUOTE=BzzBee;1337266]Excuse Me Mr/Miss Nyight.... I have more experience than you and what you think, if i had a problem, i just come to forum and start posting???? No Way, I tried to find issues from google 100 times, tried to solve issues by my own and yess most of the issues are solved by my own, but my question is, what is the purpose of this forum if no one can give timly help. If one's need to solve all the problems by own then why is this rubbish forum here???[/QUOTE]

Can you answer the questions to my own threads then?

Nyight 10

I don't think you can assign session_start() to a variable or at least I've never seen it done like that.

session_start() simply tells the server/client browser to start storing information for that specific session. After it's been started you should use $_SESSION to access the different variables unless you are requesting say the session_id, which could be done like so.
echo $id;

Look through the first link below, specifically the session functions section. You probably won't ever use most of those functions but it'll give you an idea of how to use the ones you want to use.


Nyight 10

Perhaps because no one has the answer hmm?
If it's that pressing and you don't mind feeling like an idiot... [url]http://stackoverflow.com/[/url]

[Steps to solve almost every problem]

  1. Look at the code, piece by piece.
  2. Try an alternative method to doing what you want to do.
  3. Look up information or documentation on the tools you're using.
  4. Google.
  5. Google.
  6. Google more.
  7. Get tired of google and come back later.
  8. Get a good idea and watch it fail.
  9. Go back thoroughly through the information and or documentation you've already gone through several times.
  10. Ask on a forum.
  11. While waiting for a possible solution, continue experimenting.
  12. Checking back to the forum frequently to see if there has been a reply [b][u]WHILE[/u][/b] continuing to play the trial and error game.
  13. Try a solution if the thread has received one.
  14. Repeat.

I've started 4 topics myself and only 1 has ever received a reply. The rest I had to answer on my own.

Nyight 10

Line 41

Nyight 10

That's inserting, not selecting (or fetching as previously mentioned).

Why not just add those fields into your checks on line 15? Though the response that qazplm114477 gave should do the same though I'll reiterate what he stated. If you insert the field into the database with an empty string, it will not be N/A, it will be '' as '' is an empty string and an empty string is not null.

Btw... [b]never[/b] post the password/username combo that connects to your database. Please, for your security, always replace it with a uniform set of characters. This lets us know you HAVE a password but are hiding it.

Another thing you could do is when you go to display it, put a check into the display algorithm you're using:
if(fieldname==""){echo"N/A";}else{echo fieldname;}

Nyight 10

There are 2 simplistic ways.

The first and most recommended is the header redirect:
header("Location: pagename.php");
That sends the header location to the browser, telling it to redirect itself to whatever you replace pagename with.

The second, less elegant way:

Where 2 is the number of seconds to wait before sending a refresh command to the browser and the url obviously being the page you want to redirect to.

The main problem I have with the second is that the page has to load before it even begins the countdown and witin that amount of time, if the user presses ESC or clicks the stop button, the countdown stops and the page does not redirect. The header sent by php is, as far as I've ever been able to manipulate, impossible to stop from redirecting as it's one of the very first things the browser receives.

However, the header refresh can be tricky to use. As it's a header, you [b]cannot[/b] echo or display [b]ANY[/b] kind of text or anything. If you decide to use it but cannot get it to work, just post it and we'll see what we can do.

Nyight 10

My apologies, I did not read the syntax of your query very well. Using that syntax you [b]must[/b] include all fields, including ID, which you have done.

What I'd recommend doing is making the input field within the page a readonly field and when the page loads, grab the number of rows from within the database already, add one and put that in as the value for the ID within the form. That way when it's submitted, the newest ID will be within the form and inserted into the database.

The only problem I can currently foresee would be if you deleted a few rows, as that would change the next auto-incremented value and would cause the duplicate key issue again.

As a possible solution to look into, maybe you should think about using the syntax:
/ Note the addition of the column names. THESE MUST BE CHANGED TO REFLECT THE ACTUAL COLUMN NAMES
Note that the variable $id was removed from the query
INSERT INTO newbase2 (last_name,first_name,middle_name,age,sex,course) VALUES ('$lname', '$fname', '$mname' , '$age' , '$sex', '$course')
That way you can let the database itself create and insert the ID as you add more rows, etc...

Nyight 10

Quite simple really (refer to bolded text in quote).

[QUOTE=Nyight;1337059]That's a mysql error saying that as you were trying to insert a duplicate entry into the database with, I'm assuming, an ID of 1 that is also set to auto_increment.

[b]If this is the case, don't bother trying to set the ID of the row yourself unless you're trying to rename/reorder them, line 37. Auto_increment will, as the name itself explains, increment itself. For example, if you have 3 rows in the database and you go to add another, it will automatically define the ID for the new row as 4 and so forth.[/b]


Nyight 10

Nyight 10

That's a mysql error saying that as you were trying to insert a duplicate entry into the database with, I'm assuming, an ID of 1 that is also set to auto_increment.

If this is the case, don't bother trying to set the ID of the row yourself unless you're trying to rename/reorder them, line 37. Auto_increment will, as the name itself explains, increment itself. For example, if you have 3 rows in the database and you go to add another, it will automatically define the ID for the new row as 4 and so forth.


Nyight 10

After line 18 in login.php
$u = mysql_fetch_assoc($q);
$_SESSION['id'] = $u['id'];
$_SESSION['username'] = $u['username'];

Once you have done that, in your main.php you will be able to access their username and anything else via the superglobal $_SESSION.

Another thing to consider would be to grab the users information within main.php so that you have access to whatever you want from their account.
$u=mysql_query("SELECT * FROM users WHERE id='".$_SESSION['id']."' AND username='".$_SESSION['username']."' LIMIT 1");
// log user out
$user = mysql_fetch_assoc($u);
// The $user variable now contains all information that is stored within the database.

Nyight 10

Nyight 10

Well if that's the case then use cron or a cron equivalent that runs once every say 2-3 minutes. This way "it may take time to update across the server." What you could do for your cron is what I described, make a script that "ques" up all requested logo's that need to be distributed and have the cron script "submit" the information to a "listener" file on the receiving end that would take it and process it all.

But again, this listener file would be vulnerable to attacks. Though, again theoretically, it is possible to do this if you have access to server side code on all the sites you are manipulating.

Nyight 10

[QUOTE=BzzBee;1335976]I made this title because if the thread contains title with tough problem, no one even open thread and try to help.[/QUOTE]

Definitely not true and if that has been your experiences in the past with daniweb then that's simply ridiculous. However, onto your question.

The only [b][u]theoretical[/u][/b] (I stress that because I'm only just now contemplating it) way to do that would be to use some kind of automated submission so that when you submit the file to one site, it loads the page with all necessary information and resubmits it over to your other one. But this methods requires php or some kind of server side language that can manipulate files for the image storing end.

In essence, javascript is probably your best bet here as php is limited to the server it's hosted on and cannot access another's. It would make security an absolute nightmare if servers could manipulate each others files.

If you don't mind my asking, why are you trying to accomplish this?

Nyight 10 Junior Poster in Training

I'm not sure if this should go in this forum or not so please move it accordingly if necessary.

I was wondering how difficult it would be to implement code highlighting. Personally I like to show the person where their errors might be or are without giving them a direct answer so that they can learn from what they did wrong or smile about the simplicity of it. Currently the only way I can accomplish this is to underline the section of code, this of course means I cannot use the code tags to wrap it up and make it look all pretty. Another idea if this isn't feasible is to allow the underline to be parsed within the code tags.

It would also be really nice to be able to customize the number line so if you repost their code, you could specify what line it is on.

Maybe there is already a way of doing all or a part of this and I just don't know about it?

Thanks for any help provided.

Nyight 10

You are running the query twice. Once on line 18 and again on 21. Remove line 21, edit variable names to reflect changes and it should work.

A future error on line 18:
[b]mysql_query( "UPDATE newbase2 SET lname = '".$lname."', fname = '".$fname."', mname = '".$mname."', age=[u]'".$age.", '[/u]gender = '".$txtgender."',

course = '".$course."' WHERE id = '$id' ");[/b]

Nyight 10

That's why I try to avoid cookies except to hold generic information that the scripts only reference or if they do require, cross-reference before using (e.g. it stores username/id/joined-date (unix timestamp, makes it incredibly hard to guess), check to see if all 3 pieces match up, if not, log them out). The $_SESSION variable is reasonably nice and efficient as well and is entirely based on the user's browser.

Though I'll warn you, if a hacker wants to get in or screw with your website, it's only a matter of time. You're job is just to make sure they get frustrated and give up before they find a way in ;)


Nyight 10

To understand this error you'll need to understand when each peice of code is executed. Php is parsed entirely server side. This means that the client (the person viewing the page) [b]never[/b] gets to see any of the php code (source). On the other hand, to my knowledge, javascript is only ever ran/parsed on the client.

With that in mind, fname is never defined within php so it's equivocally trying to run [b]file_get_contents('""');[/b] which will undoubtedly return an empty string.

[Note on server side js]
It would appear, after a quick [url=http://www.google.com/search?q=javascript+server+side]google[/url] search, js server side is possible but not very popular and your host must have it installed, as it's an add-on for apache, for it to work. Though this is not very practical yet, in my opinion. [url]http://www.webreference.com/programming/javascript/rg37/index.html[/url]

Nyight 10

If the ID is not suppose to be zero, you have one of potentially many problems. Start from there and work your way backwards following the "paper trail" back to where the ID is assigned to find out what's going on... if you haven't done this already that is.

Nyight 10

As you're dealing with javascript, you can easily load the page up that's not working properly and view the source. Or even in most browsers, you can click and see if the javascript is erroring at all.

Just for curiosities sake, have you tried viewing the page source for the one where you echo in the file contents into the javascript instead of into the span?

Also for P0lT10n, file_get_contents() is really nice if you're only looking to grab the information out of the file:

Nyight 10

I've tried doing this several times myself and I've only come up with one reasonably efficient method of doing this:
$keys = array_keys($_POST);
$value = $_POST[$keys[$i]];
$_POST is not an indexed array so it's impossible to iterate generically through it.

Another potential method that might work:
foreach($key in array_keys($_POST)){
$value = $_POST[$key];
Given they are pretty much the same thing though I rarely ever use foreach() so I'm not sure if this will work or not.

An html tag's ID, to my knowledge, cannot be sent when the form is submitted.[/i]


Nyight 10

To clarify on a few things, if it was a mysql_connect or just a general mysql_error, php would display the problem and then continue parsing the page until it ran into a critical error.

I've ran into situations where the page merely returns blank without any explanation whatsoever and after several days of trying to figure out what was going on, I decided to echo display_errors. My host, by default, had it disabled.

Anyway, to check to see if this is your problem, try echoing display_errors or error_reporting. If you can't get that to work, just use phpinfo() and scroll to find them. If display_errors is off then you can do several things to rectify the situation.

The most common methods are to place [b]ini_set('display_errors',1);[/b] and or [b]error_reporting(E_WARNING | E_PARSE)[/b] at the top of your page, usually the header file so it only has to be typed once.

The next most common method (as I have never been able to get ini_set() or error_reporting() to work properly) is to place a [b]php.ini file within each directory(folder) that displays pages[/b] with the single line of [b]display_errors = 1[/b]. This method has always worked for me.

Hope this helps.


qazplm114477 commented: agreed +1

Nyight 10

I've never used phpNuke before but if it operates in roughly the same manner that php does then requiring a field to be submitted does not happen on the database(sql) side, it happens during the "error checking" of the form being submitted so you can tell the user that not all the information was submitted before doing anything within the database.

Nyight 10

You're welcome :) and if all is solved make sure to mark the post as solved lol.

Nyight 10

What exactly are you trying to accomplish here? This is also javascript, specifically jQuery, not php.