|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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> |
|
#2
|
|||
|
|||
|
It looks like you're just missing a closing bracket. There are two while loops but only one of them as a closing.
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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> |
|
#5
|
||||
|
||||
|
$$result = mysql_db_query("ISSUE", $query);
change $$result to $result |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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 |
|
#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:
|
|
#9
|
|||
|
|||
|
Hi MadCowDzz,
it worked, thank you very much, this is really good stuff. Thanks again |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Search page MySQL PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|