SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 24th, 2004, 01:09 PM
Seriousdamage Seriousdamage is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 Seriousdamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 37 sec
Reputation Power: 0
Search page MySQL PHP

Hi, could someone help me find what the problem with my script is?
I am trying to build a search page that will search my database, but I keep geting an error :
Parse error: parse error in /usr/local/psa/home/vhosts/giustinianinicola.com/httpdocs/php/Srch.php on line 48
Which is the last line of my script.
Please help, PS: I am not good at this I have only just started.
Thank you very much.


<html>
<body>
<?php
if ($search) // perform search only if a string was entered.
{
mysql_connect("localhost","****","****"); // servername = localhost, username for the database, password
$db = "database"; //database name
$srch="%".$search."%";
$query = "select * from ISSUE WHERE id LIKE '$srch' || name LIKE '$srch' || surname LIKE '$srch' || phone LIKE '$srch' || status LIKE '$srch'";

$$result = mysql_db_query("ISSUE", $query);
if ($result)
{
echo "Here are the results:<br><br>";
echo "<table border=0 cellpadding=3 cellspacing=5>
<tr bgcolor=#104E8B>
<td width=10><font size=2 color=#FFFF00 face=tahoma><b>ID</b></font></td>
<td width=80><font size=2 color=#FFFF00 face=tahoma><b>First Name</b></font></td>
<td width=100><font size=2 color=#FFFF00 face=tahoma><b>Last Name</b></font></td>
<td width=50><font size=2 color=#FFFF00 face=tahoma><b>Phone</b></font></td>
<td width=50><font size=2 color=#FFFF00 face=tahoma><b>Status</b></font></td>
</tr>";

while ($r = mysql_fetch_array($result)) { // Begin while

while ($r = mysql_fetch_array($result)) { // Begin while
$id = $r["id"];
$name = $r["name"];
$surname = $r["surname"];
$phone = $r["phone"];
$status = $r["status"];
echo "<tr>
<td>$id</td>
<td>$name</td>
<td>$surname</td>
<td>$phone</td>
<td>$status</td>
</tr>";
} // end while
echo "</table>";
} else { echo "problems...."; }
} else {
echo "Search string is empty. <br> Go back and type a string to search";
}
?>
</body>
</html>

Reply With Quote
  #2  
Old November 24th, 2004, 01:31 PM
oyejorge oyejorge is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 oyejorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 13 sec
Reputation Power: 0
It looks like you're just missing a closing bracket. There are two while loops but only one of them as a closing.

Reply With Quote
  #3  
Old November 24th, 2004, 01:54 PM
Seriousdamage Seriousdamage is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 Seriousdamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 37 sec
Reputation Power: 0
Where..

Thanks a lot oyejorge, but could you please show me:
what to type
where to type it ?
Yes I know, I am that bad :-)

Thank you

Reply With Quote
  #4  
Old November 24th, 2004, 03:59 PM
Seriousdamage Seriousdamage is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 Seriousdamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 37 sec
Reputation Power: 0
White page

Hi, I think I managed to close the 'while loop'.
Now if I don't enter nothing in the search field I get the "Search string is empty. Go back and type a string to search"
Which is good, but if I enter anything else I just get a white page.

Any idea?




<html>
<body>
<?php
if ($search) // perform search only if a string was entered.
{
mysql_connect("localhost","***","****"); // servername = localhost, username for the database, password
$db = "database"; //database name
$srch="%".$search."%";
$query = "select * from ISSUE WHERE id LIKE '$srch' || name LIKE '$srch' || surname LIKE '$srch' || phone LIKE '$srch' || status LIKE '$srch'";
$$result = mysql_db_query("ISSUE", $query);
if ($result)
{
echo "Here are the results:<br><br>";
echo "<table border=0 cellpadding=3 cellspacing=5>
<tr bgcolor=#104E8B>
<td width=10><font size=2 color=#FFFF00 face=tahoma><b>ID</b></font></td>
<td width=80><font size=2 color=#FFFF00 face=tahoma><b>First Name</b></font></td>
<td width=100><font size=2 color=#FFFF00 face=tahoma><b>Last Name</b></font></td>
<td width=50><font size=2 color=#FFFF00 face=tahoma><b>Phone</b></font></td>
<td width=50><font size=2 color=#FFFF00 face=tahoma><b>Status</b></font></td>
</tr>";

//while ($r = mysql_fetch_array($result)) { // Begin while

while ($r = mysql_fetch_array($result)) { // Begin while
$id = $r["id"];
$name = $r["name"];
$surname = $r["surname"];
$phone = $r["phone"];
$status = $r["status"];
echo "<tr>
<td>$id</td>
<td>$name</td>
<td>$surname</td>
<td>$phone</td>
<td>$status</td>
</tr>";
} // end while
echo "</table>";
}
} else {
echo "Search string is empty. <br> Go back and type a string to search";
}
?>

</body>
</html>

Reply With Quote
  #5  
Old November 24th, 2004, 09:18 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
$$result = mysql_db_query("ISSUE", $query);

change $$result to $result

Reply With Quote
  #6  
Old November 25th, 2004, 02:15 AM
Seriousdamage Seriousdamage is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 Seriousdamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 37 sec
Reputation Power: 0
Hi, I did that but still geting the same result, just a white page,

just one question,
$result = mysql_db_query("ISSUE", $query);

ISSUE is the name of my table, is it right that I wrote that there or should have been something else?
Thanks

Reply With Quote
  #7  
Old November 25th, 2004, 02:18 AM
Seriousdamage Seriousdamage is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 Seriousdamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 37 sec
Reputation Power: 0
By the way, you can test it if you want:

http://www.giustinianinicola.com/php/Search.php

The delete and Modify button is not working yet, I am still learning the Search part.
Thanks

Reply With Quote
  #8  
Old November 25th, 2004, 08:18 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Try adding an or die() to the end of your query method...
Also, you need to send SQL to the database, not just the table name.

I'd recommend the following line to get all information from your ISSUE table.
PHP Code:
 $result mysql_db_query("SELECT * FROM issue"$query) or die("MySQL ERROR #".mysql_errno().": ".mysql_error()); 

Reply With Quote
  #9  
Old November 25th, 2004, 09:19 AM
Seriousdamage Seriousdamage is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 7 Seriousdamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 37 sec
Reputation Power: 0
Smile It Worked!!!

Hi MadCowDzz,
it worked, thank you very much, this is really good stuff.
Thanks again

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Search page MySQL PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway