BrentonHale Posted December 9, 2009 Share Posted December 9, 2009 Hi, I'm Brenton and I'm needing some help with php. I'm a noob when itcomes to php/MySQL or any programming language for that matter. I'mcurrently taking an online class in the both (php/MySQL) and I'm onlyin the second week, so I don't know much and please bare with me.Anyway, here is what I need help with: <html> <head> <title>Hale's Music World: Inventory Search Results</title> </head> <body> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="56%" id="table1" height="129"> <tr> <td bgcolor="#008000"> </td> </tr> <tr> <td> <p align="center"><font size="5" color="#0000FF"><b>Inventory Search Results</b></font></td></tr> <tr> <td bgcolor="#008000"> </td> </tr> <tr> <td> <p align="center"> </td> </tr> <tr> <td width="99%" align="center"> <p align="left"><font color="#0000FF"><b>Your search resulted in the following records:</b></font></td></form></tr> <tr> <td width="99%" align="center"> <p align="left"> <?php $link = mysql_connect('localhost', 'halesuser', 'hales123db'); mysql_select_db('halesmusicworld'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); if ($search_type==1) { $artist_search=($_POST ['Artist_Search'] ) . '!' ; $query= "select * from inventory where artist like '%".$artist_search."%'"; $query_results=mysql_query($query); $match_results=mysql_num_rows($query_results); echo 'Number of matching records='.$match_results. '<hr>'; } If ($search_type==2) { $title_search=($_POST ['Title_Search'] ) . '!' ; $query= "select * from inventory where title like '%".$title_search."%'"; $query_results=mysql_query($query); $match_results=mysql_num_rows($query_results); echo 'Number of matching records='.$match_results. '<hr>'; } If ($search_type==3) { $genre_search=($_POST ['Genre'] ) . '!' ; $query= "select * from inventory where genre like '%".$genre_search."%'"; $query_results=mysql_query($query); $match_results=mysql_num_rows($query_results); echo 'Number of matching records='.$match_results. '<hr>'; } ?> </td> </tr> <tr> <td align="center"> </td> </tr> <tr> <td align"center" bgcolor="#008000"> </td> </tr> </table> <p align="center"><i><a href="halesmusicworld_home.html"><font face="Arial" size="5">Return to</font></a><font face"Arial" size"5"><a href="HalesMusicWorld_Home.html">Hale's Music World Home</a></font></i></p> </body> </html> The html part of the code will load and it say's it's "Connected successfully" However, I'm getting the following code errors on three lines Notice: Undefined variable: search_type in C:\wamp\www\inventory_search.php on line 36 Notice: Undefined variable: search_type in C:\wamp\www\inventory_search.php on line 46 Notice: Undefined variable: search_type in C:\wamp\www\inventory_search.php on line 55 Thanking you in advance for all the replies! Link to comment https://forums.phpfreaks.com/topic/184533-php-help/ Share on other sites More sharing options...
Philip Posted December 9, 2009 Share Posted December 9, 2009 $search_type doesn't have a value set to it (you never did $search_type = 'blah') Link to comment https://forums.phpfreaks.com/topic/184533-php-help/#findComment-974171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.