franknu Posted May 28, 2007 Share Posted May 28, 2007 <? if ( isset($_SESSION['User_Name']) && isset ($_SESSION['Password']) ) { $query = "SELECT * FROM business_info where $_SESSION['User_Name'] AND $_SESSION['Password']"; } ?> my error arse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/townsfin/public_html/authorization/text_update.php on line 69 Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/ Share on other sites More sharing options...
trq Posted May 28, 2007 Share Posted May 28, 2007 Your query wont cause a parse error. it will choke mysql though as it has an invalid WHERE clause. Lets fix the parse error first, We need more code. (At least 10 lines prior to line 69) Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/#findComment-263389 Share on other sites More sharing options...
redarrow Posted May 28, 2007 Share Posted May 28, 2007 <?php //database connection. if ( isset($_SESSION['User_Name']) && isset ($_SESSION['Password']) ) { $query = "SELECT * FROM business_info where ".$_SESSION['User_Name']." AND ".$_SESSION['Password']."" ; $result=mysql_query($query); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/#findComment-263390 Share on other sites More sharing options...
MadTechie Posted May 28, 2007 Share Posted May 28, 2007 Note thats assumes $_SESSION['User_Name'] = something like user = 'username' etc maybe $query = "SELECT * FROM business_info where user='".$_SESSION['User_Name']."' AND pass='".$_SESSION['Password']."'" ; OR (i find this easier to read) $query = "SELECT * FROM business_info where user='{$_SESSION['User_Name']}' AND pass='{$_SESSION['Password']}'" ; of course change user & pass to the correct field names Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/#findComment-263392 Share on other sites More sharing options...
franknu Posted May 28, 2007 Author Share Posted May 28, 2007 well, i tried diffrent things and nothing is selecting from the database so i will add more codes to give u guys a better idea here it is <?php session_start(); $_SESSION['User_Name']; $_SESSION['Password']; ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style1 { color: #FFFFFF; font-weight: bold; } --> </style> </head> <body> <?php // i just removed data info $host = ""; $username = "ocalho"; $password = "abc123"; $database = ""; $db = mysql_connect($host, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $BusinessName = (isset($_POST['BusinessName']) ? $_POST['BusinessName'] : ''); $Slogan = (isset($_POST['Slogan']) ? $_POST['Slogan']:''); $Business_Address = (isset($_POST['Business_Address']) ? $_POST['Business_Address']:''); $Tel = (isset($_POST['Tel']) ? $_POST['Tel']:''); $Website = (isset($_POST['Website']) ? $_POST['Website']:''); $Email = (isset($_POST['Email']) ? $_POST['Email']:''); $Member_Status = (isset($_POST['Member_Status']) ? $_POST['Member_Status']:''); $Fax =(isset($_POST['Fax']) ? $_POST['Fax']:''); $type = (isset($_POST['type']) ? $_POST['type']:''); $make = (isset($_POST['make']) ? $_POST['make']:''); $Categories = (isset($_POST['Categories']) ? $_POST['Categories']:''); $Keyword = (isset($_POST['Keyword']) ? $_POST['Keyword']:''); $Picture1 = (isset($_POST['Picture1']) ? $_POST['Picture1']:''); $Headline = (isset($_POST['Headline']) ? $_POST['Headline']:''); $Slogan2 = (isset($_POST['Slogan2']) ? $_POST['Slogan2']:''); $Description1 = (isset($_POST['Description1']) ? $_POST['Description1']:''); $Description2 = (isset($_POST['Description2']) ? $_POST['Description2']:''); $Description3= (isset($_POST['Description3']) ? $_POST['Description3']:''); $Contact2 = (isset($_POST['Contact2']) ? $_POST['Contact2']:''); $Picture2 = (isset($_POST['Picture2']) ? $_POST['Picture2']:''); $Picture3 = (isset($_POST['Picture3']) ? $_POST['Picture3']:''); $Picture4 = (isset($_POST['Picture4']) ? $_POST['Picture4']:''); $User_Name = (isset($_POST['User_Name']) ? $_POST['User_Name']:''); $Password = (isset($_POST['Password']) ? $_POST['Password']: ''); if ( isset($_SESSION['User_Name']) && isset ($_SESSION['Password']) ) { $query = "SELECT * FROM business_info where User_Name='".$_SESSION['User_Name']."' AND Password='".$_SESSION['Password']."'" ; $result=mysql_query($query); } ?> <table width="356" border="0"> <tr> <td width="346"><table width="514" border="1"> <? echo"$BusinessName"; $_SESSION['User_Name']; $_SESSION['Password']; ?> <pre>_SESSION:<?php print_r($_SESSION); ?></pre> <tr> <td width="504" background="fondo2.jpg"> </td> </tr> <tr> <td><table width="537" border="1" bordercolor="#E0DFE3" bgcolor="#CCCCCC"> <tr> <? echo'<form action="'. $_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">'; ?> <td width="67">Business Name </td> <td width="148"> <? echo" <input type=\"text\" name=\"BusinessName\" value=\"{$row['BusinessName']}\"> "; ?> thank u Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/#findComment-263397 Share on other sites More sharing options...
trq Posted May 28, 2007 Share Posted May 28, 2007 nothing is selecting from the database How do you know? You never actually use the results of your query. Did you solve the parse error? Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/#findComment-263400 Share on other sites More sharing options...
franknu Posted May 28, 2007 Author Share Posted May 28, 2007 i fixed the parser and this should display the results if it is selecting from database $result=mysql_query($query); <? echo"BusinesName"; ?> this is my Display when i echo the query SELECT * FROM business_info where User_Name='franklin' AND Password='franklin01' Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/#findComment-263404 Share on other sites More sharing options...
trq Posted May 28, 2007 Share Posted May 28, 2007 and this should display the results if it is selecting from database <? echo"BusinesName"; ?> How? All that will echo is the words BusinesName. An example.. <?php // connect if ($result = mysql_query("SELECT foo FROM tbl")) { if (mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo $row['foo'].'<br />'; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53299-how-to-do-this-query-i-am-getting-a-parser-error/#findComment-263407 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.