mby247 Posted May 23, 2010 Share Posted May 23, 2010 Hi member, am creating a shipping website with tracking page but I have problem with my php coding. I want only the tracking number entered into the tracking page to run MySql record on the database but with the code below, even any number i input or even with no input on the track page, would still run the database. Please I need help on...only the tracking number can run the record on MySQl. If my coding is wrong..pls correct me. ===================================================== <html> <body> <?php //Connect To Database $hostname='*********'; $username='*********'; $password='*********'; $dbname='**********'; $usertable='3456746my'; mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); //This array contains all correct tracking numbers $correct_tracking_numbers=array(22333); if(in_array(22333,$correct_tracking_numbers)){ $query = 'SELECT * FROM ' . $usertable; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['Date/Time'] . " " . $row['Event']. " ". $row['Location']. " " . $row['Details'] . "<br/>"; } }else{ echo '<b>The tracking number you entered is not valid!</b>'; } ?> </body> </html> ================================================ Thanks all for reading and would appreciate a reply and help. Quote Link to comment Share on other sites More sharing options...
-Karl- Posted May 23, 2010 Share Posted May 23, 2010 Explain a bit more what it's actually doing, and what you'd like it to do. I'd also suggest removing your Database information. Quote Link to comment Share on other sites More sharing options...
mby247 Posted May 23, 2010 Author Share Posted May 23, 2010 I do I remove my database info? Please advice cos there is no place for editing....? Actually am building a shipping firm website with track page. So the I want how to create tracking number so that it would run the record and table in mysql. Pls help. Quote Link to comment Share on other sites More sharing options...
ignace Posted May 23, 2010 Share Posted May 23, 2010 even any number i input or even with no input on the track page, would still run the database. $correct_tracking_numbers=array(22333); if(in_array(22333,$correct_tracking_numbers)){ Is also always true. Like -Karl- said what do you want it to do? Quote Link to comment Share on other sites More sharing options...
mby247 Posted May 23, 2010 Author Share Posted May 23, 2010 I want only the number assigned like in the $correct_tracking_number can run the query on Mysql cos even if I input wrong number or no input at all....mysql still run. I try using the key_exist() but it is not working. Pls help or advice on wat to do if I want a tracking number to run the query in mysql database. Quote Link to comment Share on other sites More sharing options...
ignace Posted May 23, 2010 Share Posted May 23, 2010 Post your entire script as it is because if the script is as you posted it above then you already know what the problem is. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.