GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 4.50 average.
  #31  
Old 04-Jul-2006, 13:43
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Florina, Greece
Posts: 1,112
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'


Quote:
Originally Posted by killaz
damn i missed that too lol. Thanks man it works like a charm. i missed it because im not good at php, but thanks again.

You're Welcome.


Mark

BTW, welcome to GIDForums™. You were clear about your problem and used code tags. Makes it easy to help.
__________________

"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs

Stories from the NICU Blog
  #32  
Old 04-Jul-2006, 21:41
killaz killaz is offline
Awaiting Email Confirmation
 
Join Date: Jul 2006
Posts: 4
killaz is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


yeah im used to forums.
  #33  
Old 31-Aug-2009, 23:46
urstrulydj urstrulydj is offline
New Member
 
Join Date: Aug 2009
Posts: 1
urstrulydj is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


hi,
i'm new to this forum. i'm trying to install a script which gives me same error

expecting
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in line 585


$output = '<?php
$license="' . $_REQUEST['licensekey'] . '"; <THIS IS LINE 585>
$db_host = "' . $_REQUEST['dbhost'] . '";
$db_username = "' . $_REQUEST['dbusername'] . '";
$db_password = "' . $_REQUEST['dbpassword'] . '";
$db_name = "' . $_REQUEST['dbname'] . '";
$cc_encryption_hash = "' . $str . '";
  #34  
Old 02-Sep-2009, 19:42
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,441
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


Know that the error could also exist BEFORE the point where the parser thinks it happened.

Look at the line before 585. The 'output' assignment appears to be incomplete.
From the way it looks, that line should actually appear like this:
PHP Code:

$output = '<?php'; 


__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #35  
Old 23-Jan-2010, 00:55
dmlina28 dmlina28 is offline
New Member
 
Join Date: Jan 2010
Posts: 17
dmlina28 is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


I,m also new in programming in PHP and I have problems with error like in subject in this topic.

I've made search form and search.php file which should do the work of searching table "roba" against column "naziv" in my MySQL database. Here is the code of search.php file.


PHP Code:

<?php

if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/[A-Z | a-z]+/", $_POST['naziv'])){
$naziv=$_POST['naziv'];

//connect to the database
$db=mysql_connect ("localhost","iwa_2008","FOI") or die ('Konekcija nije uspjela zbog: ' . mysql_error()); 

//-select the database to use
$mydb=mysql_select_db("iwa_2008_kz_projekt");

//-query the database table
$sql=SELECT naziv,roba,cijena,kolicina,url_foto FROM roba WHERE naziv LIKE '%" . $naziv . "%';

//-run the query against the mysql query function
$result=mysql_query($sql);

//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){

$naziv = $row['naziv'];

//-display the result of the array

echo "<ul>\n"; 
echo "<li>"<a href="search.php?roba=$roba\">" . $naziv . "/a></li>\n"; 
echo "</ul>";
}
}
}
}
?>


This is simple source of search form (if needed).

HTML Code:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Search Contacts</title> <style type="text/css" media="screen"> ul li{ list-style-type:none; } </style> </head> <body> <h3>Search Contacts Details</h3> <p>You may search either by first or last name</p> <form method="post" action="search.php" id="searchform"> <input type="text" name="name"> <input type="submit" name="submit" value="Traži"> </form> </body> </html>

After entering and submiting serach word I get error

Code:
Parse error: parse error in D:\Program files\wamp\www\Search forma\search.php on line 15

I would appreciate if anyone could check the syntax of search.php and tell me what should be changed to make it work. The problem is probably very trivial but as I said, I new in this so please have understanding

Thanks in advance.
Last edited by admin : 23-Jan-2010 at 01:32. Reason: Please insert your example PHP codes between [PHP] and [/PHP] tags
  #36  
Old 23-Jan-2010, 08:22
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,441
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


Take a close look at this line:
PHP Code:

//-query the database table
$sql=SELECT naziv,roba,cijena,kolicina,url_foto FROM roba WHERE naziv LIKE '%" . $naziv . "%'; 


The quoting is off (at the start, and the very end). Also note that you can 'embed' a variable directly in a string [must be inside a double-quoted string] to reduce concatenation, like so:
PHP Code:

//-query the database table
$sql="SELECT naziv,roba,cijena,kolicina,url_foto FROM roba WHERE naziv LIKE '%{$naziv}%'"; 


Note that the curly braces { } surrounding the variable will NOT remain in the string. There will also a be string issue with one of your echo statements. Try to resolve it, but if uncertain, post another reply.
HTH
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #37  
Old 25-Jan-2010, 04:18
dmlina28 dmlina28 is offline
New Member
 
Join Date: Jan 2010
Posts: 17
dmlina28 is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


Thanks for instruction for SQL query. That solved problem with error and I also tried to make some other modification inside source code of search.php but now I don't get eny error nor search result after submiting search term.

I think it's important to mention that coloumn "roba" is primary key of table which is also called "roba".

After trying to submiting search without any term I doesn't get notification "Please enter a search query" which should be displayed in that case. It obviously have something to do with curly braces that you mentioned in previous post.

Here is code after saved modifications.

PHP Code:

<?php

if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/[A-Z | a-z]+/", $_POST['naziv'])){
$naziv=$_POST['naziv'];

//connect to the database
$db=mysql_connect ("localhost","iwa_2008","FOI") or die ('Could not connect: ' . mysql_error()); 

//-select the database to use
$mydb=mysql_select_db("iwa_2008_kz_projekt");

//-query the database table
$sql="SELECT naziv,roba,cijena,kolicina,url_foto FROM roba WHERE naziv LIKE '%{$naziv}%'";

//-run the query against the mysql query function
$result=mysql_query($sql);

//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){

    $naziv = $row['naziv'];
    $roba = $row['roba'];
    $cijena = $row['cijena'];
    $kolicina = $row['kolicina'];
    $url_foto = $row['url_foto'];

//-display the result of the array

echo "<ul>\n"; 
echo "<li>" . "<a href=\"search.php?roba=$roba\">" . $naziv . "</a></li>\n";
echo "</ul>";
}
}
else{
echo "<p>Please enter a search query</p>";
}
}
}
?>


Any suggestion what to change.
  #38  
Old 25-Jan-2010, 06:40
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,441
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


No, there should be no issues with the curly braces...

I'm not clear how this is used?
PHP Code:

if(isset($_GET['go'])){ 


I don't see how/where 'go' is ever set, and the statement that you expect to see is inside this condition, so it is simply not getting there. Maybe you could add [temporarily, at least] an else condition to that block that might print, "No Go."
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #39  
Old 25-Jan-2010, 09:46
dmlina28 dmlina28 is offline
New Member
 
Join Date: Jan 2010
Posts: 17
dmlina28 is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


I found instructions how to use this code on http://www.webreference.com/programming/php/search/index.html and I just tried to customize code for my database but I can't make it work.

It would be best that you read the instructions and see explanation on using "if(isset($_GET['go']))".
  #40  
Old 25-Jan-2010, 10:01
dmlina28 dmlina28 is offline
New Member
 
Join Date: Jan 2010
Posts: 17
dmlina28 is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


In search form, I've made correction of this line

Code:
<form method="post" action="search.php?go" id="searchform">

which uses "if(isset($_GET['go']))" line in search.php file. After this change (when search term is submited) I'm getting error

Code:
Notice: Undefined index: naziv in D:\Program files\wamp\www\Search forma\search.php on line 5 Please enter a search query
 
 

Recent GIDBlogCompress Your Web Site by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:05.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.