Hi I am a newbie trying to get some of my first code working, yada yada yada.
I have a drop down box which chooses a state then takes the post data to 'processform2.p hp' to use that to pull up all the rows which have the corresponding state.
I am getting this 'Parse error: syntax error, unexpected T_STRING in /home/attorney/public_html/' on line 13 - <?
-
$username="XXXXXXXX";
-
$password="XXXXXX";
-
$database="XXXXXXXX";
-
-
-
ini_set('display_errors',1);
-
error_reporting(E_ALL);
-
-
-
mysql_connect("localhost",$username,$password);
-
@mysql_select_db($database) or die( "Unable to select database");
- $query='SELECT * FROM BIZ_APARTMENTS WHERE $_POST('bizState')';
-
$result=mysql_query($query);
-
-
$num=mysql_numrows($result);
-
-
mysql_close();
-
-
echo "<b><center>Buildings in State</center></b><br><br>";
-
-
$i=0;
-
while ($i < $num) {
-
-
$name=mysql_result($result,$i,"bizName");
-
$address=mysql_result($result,$i,"bizAddress");
-
$city=mysql_result($result,$i,"bizCity");
-
$state=mysql_result($result,$i,"bizState");
-
$zip=mysql_result($result,$i,"bizZip");
-
$phone=mysql_result($result,$i,"bizPhone");
-
$email=mysql_result($result,$i,"bizEmail");
-
-
echo "<b>Name: $name</b><br>Phone: $phone<br>Type: $type<br>Address: $address<br>City: $city<br>State: $state<br>Zip: $zip<br>Email:$email<br>";
-
-
$i++;
-
}
-
-
?>
Thanks a million,
Dec 16 '09
14 5509 kovik 1,044
Recognized Expert Top Contributor
OMFG! That is the syntax that my query() function in my database uses. o.o - /**
-
* Query the database
-
* @param string Database query
-
* @param array Values to substitute into query
-
* @return Vol_Database_MySql
-
*/
-
public function query($query, array $substitutions);
Replaces values from $substitutions into the places that question marks are in $query (using mysql_real_esca pe_string and typecasting of numeric values). I thought it was clever and original >.<
for instance if i select Iowa, i get back 'Array ( [b] => IA )' What does the 'b' before the '=>' stand for? Also how do i get the post data to be used as part of the 'where' so that only rows with column 'bizState' matching $_POST are pulled.
I plead my massive ignorance as I try to teach myself here. Again many thanks for your patience.
thank you,thank you,thank you,thank you...
kovik 1,044
Recognized Expert Top Contributor
"Array ( [b] => IA )" means that the array has an element at index "b" that has the value "IA".
In order to access th value "IA", you want to access the "b" index. So, your query should be: - $query = "SELECT * FROM $table WHERE bizState='"
-
. mysql_real_escape_string($_POST['b']) . "'";
how freakin cool, it actually WORKS!!!
Can I Pick Your Brains A Little Further?...
Can you give me a general idea on how I could take these results and turn them into a page full of links each one pointing to a separate page for each result.
I think i understand a little how to concatenate together a url from the results, but do i point it to a template or something to generate a gazillion pages from the results or what?
Many thanks from a newbie fumbling in the dark.
kovik 1,044
Recognized Expert Top Contributor
You'll likely want to make use of the query string. The query string is the part of a URL that is followed by a question mark (?). It is a series of variables and values that will exist in the $_GET array. Example: - // index.php
-
$result = mysql_query("select `id`, `name` from `table`");
-
-
while ($data = mysql_fetch_object($result)) {
-
echo '<a href="item.php?id=', $result->id, '">', $result->name, '</a>';
-
}
- // item.php
-
$item = null;
-
-
if (isset($_GET['id'])) {
-
$id = (int)$_GET['id'];
-
$result = mysql_query("select * from `table` where `id` = {$id}");
-
$item = mysql_fetch_object($result);
-
}
-
-
if (!$item) {
-
echo 'Invalid item.';
-
} else {
-
echo 'Item name: ', $item->name;
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steven |
last post by:
I got a "Parse error: parse error in ..." in this line:
if(empty($_POST){
.....
But if I fist assign $ssn=$_POST; and then if(empty($ssn){ ... it is
working.
Any advice? Thanks in advance.
|
by: Andrew E |
last post by:
Hi all
I've written a python program that adds orders into our order routing
simulation system. It works well, and has a syntax along these lines:
./neworder --instrument NOKIA --size 23 --price MARKET --repeats 20
etc
However, I'd like to add a mode that will handle, say:
|
by: |
last post by:
Some time ago I installed VC# 2003, made a small generic project, compile
with the allow unsafe flag and I get the error below:
"error CS1577: Assembly generation failed -- Unexpected exception
processing attribute -- System.ArgumentException: Invalid directory on URL."
(If I do not compile with the unsafe flag compiler setting all compiles
perfect)
After long tracing, I ended up discovering that it is csc.exe installed by
the .NET...
|
by: Flip |
last post by:
I know the int.Parse("123") will result in an int of 123, but what happens
with a null? I believe it give a null exception (seems like I get either
NullArgumentException or ArgumentNullException if I'm running it in a
console app or in a web app, what's up with that?).
I'm trying to get a counter (int) value out of the Application object. When
I do the Convert.ToInt32(Application), the first time (it's
null), the method converts it to...
|
by: pinky |
last post by:
Hi all
I am having one web service where in at a time of calling one webmethod
through client application i am continuously getting following error :-
The underlying connection was closed: An unexpected error occurred on a
| |
by: jacqueharper |
last post by:
I am having a problem with an Excel ListObject in my C# .NET
application. I am trying to map an XML schema to a ListObject, and
continue to get the error "The XPath is not valid because either the
XPath syntax is incorrect or not supported by Excel." No matter what
crazy things I try, I can not either get it to work, or get a
different, more interesting error message. :-)
I have created my ListObject, and added a schema to my XmlMaps.
...
|
by: comp.lang.tcl |
last post by:
set php {<? print_r("Hello World"); ?>}
puts $php; # PRINTS OUT <? print_r("Hello World"); ?>
puts
When I try this within TCL I get the following error:
|
by: JToe |
last post by:
Hi,
I have a sql statement which is as follows:-
INSERT INTO expense(Jan) SELECT sum(ECFAmount) FROM Transaction WHERE Date BETWEEN (#01/01/2007#) AND (#01/31/2007# )
When i execute the above, I have an error like this >>
java.sql.SQLException: Too few parameters. Expected 1.
can someone pls suggest or advise me what can be the problem?
|
by: ana10192000 |
last post by:
VB6.0
Private dbParts as Database
Private dbParts as Recordset
guys help, i can't execute my program
compiler error says: " user-defined type not defined "
i'm not much a knowledgable programmer, i'm still just a student, do explain it in a little bit detailed statements.
thanks!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |