johlwiler Posted September 6, 2007 Share Posted September 6, 2007 Hey, I have a page that the session_start() statement does not work unless I put a @ in front of it. I have seen in some tutorials where people do this not just in sessions but also in mysql calls. I have never had to use this in my code before and have just seen it around in a few other code. Does anyone the purpose of the @ symbol, or why it makes a difference? I couldn't really find an answer anywhere else so I am just straight up asking. Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/ Share on other sites More sharing options...
trq Posted September 6, 2007 Share Posted September 6, 2007 The @ symbol is the error supressor. Placed in front of a function call it will stop any errors caused by said function call from being displayed. Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/#findComment-342695 Share on other sites More sharing options...
johlwiler Posted September 6, 2007 Author Share Posted September 6, 2007 so does that function still work. My sessions still seem to work, and I can't figure out why the session_start() the header could be sent before the session_start(); is this a common problem with session? is that why a lot if people using sessions do that. Here is my code <?php @session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>World Properties Online</title> <meta name="keywords" content="glossary,property,real estate,rental,commercial,sale,by owner" /> <meta name="description" content="Welcome to World Properties Online, your guide to property for sale around the world." /> <link href="wpo.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> </div> <div id="navigation"> <ul id="navigation"> <li><a href="index.php">Home</a></li> <li><a href="listproperty.php">List Property</a></li> <li><a href="searchform.php">Search Properties</a></li> <li><a href="http://www.towd.com" target="_blank">Tourism Info</a></li> <li><a href="http://www.onlinenewspapers.com/" target="_blank">Newspapers</a></li> <li><a href="faq.php">FAQs</a></li> <li><a href="prices.php">Prices</a></li> <li><a href="glossary.php">Glossary</a></li> <li><a href="contactus.php">Contact Us</a></li> <li><a href="/blog/index.php">Blog</a></li> </ul> </div> <?php if(!isset($_SESSION['username'])){ echo ("<div id='column'> <form action='login.php' method='post' name='login' class='cmxform'> <fieldset class='login'> <legend>User Login</legend> <ol> <li> <label for='username'>Username</label> <input id='userName' name='userName' type='text' /> </li> <li> <label for='PW'>Password</label> <input id='PW' name='PW' type='password' /> </li> <input type='submit' class='submit' value='Submit'/> </ol> </fieldset> </form>"); }else{ echo(" <div id='column'> <fieldset class='login'> <legend>User Login</legend> <ul> <li> <label for='username'>Logged in as ".$_SESSION['username']." </label> </li> <li> <a href='logout.php'>Log Out</a> </li> <li ><a class='control' href='control/editprofile.php'>Edit Your Profile</a><br /> <a class='control' href='control/properties.php'>Manage Your Listings</a><br /> <a class='control'href='control/payment.php'>Pay For Listings</a></li> </ul></fieldset>"); } ?> <ul id="related"> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=1"> Africa</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=2">Asia</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=3">North America</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=4">South America</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=5">Cental America</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=6">Pacific Islands</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=7">Europe</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=8">Australia</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=9">Caribbean</a> <li><a href="https://www.worldpropertiesonline.net/searches.php?cont=10">Other</a> </ul> </div> <div id="area"> <div class="content"><h2>Welcome to World Properties</h2><a href="listproperty.php"><img class="float" src="images/getstarted.jpg" alt="" /></a> <p>Welcome to World Properties Online, your virtual classifieds guide to property for sale, rent or lease around the world. Our site is designed to provide property the widest possible exposure on the American and International market, in an effective and professional format.</p> <p>Listing with us makes your property more accessible to individuals looking to buy, rent or lease property throughout the world. It also complements any local advertising campaigns you have, and for Real Estate Professionals, it provides greater exposure of the property worldwide.</p> <p>Together, we can achieve the results you desire!</p> <a class="greylink" href="listproperty.php">Click here to get started listing your property...</a> </div> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/#findComment-342698 Share on other sites More sharing options...
trq Posted September 6, 2007 Share Posted September 6, 2007 Your probably getting a warning, not an error. Errors will stop the function call from working. You should avoid using @ wherever possible. It usually points directly to poor coding practices. Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/#findComment-342700 Share on other sites More sharing options...
teng84 Posted September 6, 2007 Share Posted September 6, 2007 the warning message is the only error that can be suppressed by the @ Personally I dont use @ and hate the @ this is for lazy people Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/#findComment-342701 Share on other sites More sharing options...
johlwiler Posted September 6, 2007 Author Share Posted September 6, 2007 I see what you mean. I have always been able to do my code with out it. But the only way I can make my sessions work on that page is with the @ symbol. I overall I don't think I like it. Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/#findComment-342702 Share on other sites More sharing options...
teng84 Posted September 6, 2007 Share Posted September 6, 2007 because session declaration should be on the top most of the page without any white space and other stuff Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/#findComment-342708 Share on other sites More sharing options...
johlwiler Posted September 6, 2007 Author Share Posted September 6, 2007 Thanks guys for your input. Quote Link to comment https://forums.phpfreaks.com/topic/68163-solved-session-and-syntax-questions-with/#findComment-342757 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.