The PHP Group Computers & Internet - Page 3 - Recent Questions, Troubleshooting & Support
I keep getting error for line 15
There's too much apostrophes in define('EMAIL_SUBJECT', ... Is this line 15?
Change it to define('EMAIL_SUBJECT', "Enquiry from 'MMSWEETS'");
Php counter
You might want to note that this is not the most effective manner of creating a counter in PHP. On a few of my websites, I find it is much more effective to simply create a text file, eg. counter.txt and have PHP read that every time the page is loaded, instead of running a MySQL query. Then, have PHP also update the counter.txt file by adding 1 to the number already listed in the file and read to the user.
Clarification
are you saying you're switching from a session variable to a cookie?
delete the cookie altogether by setting the expiration to a time in the past (negative value). don't forget that you'll then have to reload a page in order to reread the cookie data.
so if you have a cookie with a logged_in value = true, and you set it to logged_in value = false, you're still logged_in = true, until you reload that page (or another page) and it rereads the cookie data and now determines that logged_in = false.
make sense? write the logged_in=false to the cookie, then force a url redirection to reload the page is my suggestion.
Dissappearing spaces when html page handles database data
Mark, it sounds like when you are displaying the data back to check and edit the data, you are not including it inside of quotes.
example:
//query to grab example data
$query="select name,salary from employee";
$result=mysql_query($query)
or die("query failed!");
printf("<input type='text' value='%s'>",mysql_result($result,0,"name"));
printf("<input type='text' value='%s'>",mysql_result($result,0,"salary"));
notice in my example the "value" argument of the "<input>" command the %s for your variable is contained within single quotes.
Retrieving and displaying logged in users info
you had not provided complete detail that if you are having database for username or you want to fetch username from 'email providing site' in which your user created his account.if you are trying for second option,It is almost not possible coz any of the email providing site will not exchange personal detail of any of his acc holder.
if you are trying first option,session in php can help you.you can store username in a session variable n then u can access them on any page if session is not destroyed or expired.
Php assigning value to variables and posting
You can use a session variable.
First use session_start().
Then you can crate a session variable by simply setting the appropriate member of the $_SESSION or $HTTP_SESSION_VARS (PHP < 4.1.0) array
Example.
session_start();
$_SESSION["number"] = 10 ;
echo $_SESSION["number"];
You can call it whenerver you want.
remmember to start session on all the pages where you use the variable.
Logout script with session management in php5
just create a logout.php script with the following
<?php
session_start();
session_destroy();
header("Location: index.php");
?>
Have your logout button/link/whatever just open that page which connects to the session with session_start. Session destroy does exactly what it sounds like... it unsets all session data and tells the server to end the session. The header request then just re-directs the user to whatever page you want after (just change out index.php)
PHP issues with ''''... Please help!!!
Hello.
If you want PHP to use quotation marks you have to seperate them from the ones that start the expression by a backslash(\).
Here are two examples:
WRONG: echo "A "QUOTE" AND SOME TEXT";
RIGHT: echo "A \"QUOTE\" AND SOME TEXT";
or
WRONG: echo 'A 'QUOTE' AND SOME TEXT';
RIGHT: echo 'A \'QUOTE\' AND SOME TEXT';
I hope this helps.
Kind Regards,
Wilhelm@X-ex.info
Logout problem
Hey,
what code are you using to destroy the session?
should look something like this
e.g. getting rid of email session
<?php
unset($_SESSION['email']);
?>
Database talks to code but code won't talk to database
Make sure you are connecting to the database,then just before you call your sql to insert use an echo statement to display the sql and check it for syntax:-
$sql = 'insert into table1 values('.$no.','.$no.',"block","'.$value3.'", "'.$value4.'")';
echo "SQL ==>" STARTOFSQL<br>".$sql." ENDOFSQL<br>";
Echo PHP
Print outputs a single string, echo can output multiple strings. (It's in the help file.)
Integrating JavaScript within PHP....
If you're trying to do this with PHP, you might be more successful creating an initial page with the buttons that should be enabled at the start (New, Update, Delete), and then create a sub-page that displays a different form depending on the action the user selected previously. This way, the user only sees the buttons relevant to his/her current action. Here's some beginning code to help you out:
<?php
$action = $_POST['action'];
if($action == 'new')
{
//display the form for creating a new conference leader
}
else if ($action == '$update')
{
//display the form for updating a conference leader
}
et cetera.
Each sub-form would be processed by a third-level page (e.g. handle_create.php, handle_delete.php, etc.)
Php cookie problems
can u give me the error that is shown when you try to use cookies ? or it just doesn't work ?
PHP Login Problem
We'd have to see the relevant code (not all of it, just the relevant part) to even guess at the problem.
PHP Guestbook Error
There's supposed to be a file named LouisSahagunGuestbookdb.php in the /home/content/p/l/a/planet9/html/LouisSahagun/ directory and there isn't any.
Not finding what you are looking for?