bruceleejr Posted December 26, 2009 Share Posted December 26, 2009 I have a few fields in the "testing" table, Im only trying to retrieve information from the "fn" & "ln" fields which stand for First Name and Last Name Its outputting the custom error message "cant select tables" Hmm whats the problem~??? <? mysql_connect('mysql5.000webhost.com', 'a3393387_c2use', '******', 'a3393387_c2db') or die('error conecint'); echo "Connected to database <br />"; $query = "SELECT * FROM testing"; $result = mysql_query($query) or die('cant select tables'); while($row = mysql_fetch_array($result));{ echo $row['fn'] . " - " . $row['ln']; echo "<br />"; } ?> its this page http://testo.comoj.com/grab.php Some extra details: Apache ver. 2.2.13 (Unix) PHP version 5.2.* MySQL ver. 5.0.81-community Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/ Share on other sites More sharing options...
trq Posted December 26, 2009 Share Posted December 26, 2009 You've passed your database name to mysql_connect which does not except it as an argument. mysql_connect('mysql5.000webhost.com', 'a3393387_c2use', '******') or die('error conecint'); mysql_select_db('a3393387_c2db'); Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984139 Share on other sites More sharing options...
bruceleejr Posted December 26, 2009 Author Share Posted December 26, 2009 Worked perfect~! Everytime you submit something here "http://testo.comoj.com/custom2.html" it gets outputted here "http://testo.comoj.com/custom2.php" which is what I want =] But now since I got "-" the dash to seperate the fields, a line of dashes gets inserted into the database. Watch, refresh the custom2.php and it automatically creates a new line of dashes that inserted into the database. How can I stop that~?? Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984287 Share on other sites More sharing options...
trq Posted December 26, 2009 Share Posted December 26, 2009 Post the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984303 Share on other sites More sharing options...
bruceleejr Posted December 26, 2009 Author Share Posted December 26, 2009 <? $fn = $_POST["fn"]; $ln = $_POST['ln']; $ff = $_POST['ff']; $fh = $_POST['fh']; $yb = $_POST['yb']; $mar = $_POST['mar']; $dbc = mysqli_connect('mysql5.000webhost.com', 'a3393387_c2use', '******', 'a3393387_c2db') or die('Cant connect to MySQL servies~!!'); $query = "INSERT INTO testing (fn,ln, " . " ff, fh, yb, mar) " . " VALUES ('$fn', '$ln', '$ff', '$fh', '$yb', '$mar')"; $result = mysqli_query($dbc, $query) or die('error querying database'); mysql_connect('mysql5.000webhost.com', 'a3393387_c2use', '******') or die('error conecint'); echo "Connected to mysql~! <br />"; mysql_select_db('a3393387_c2db'); echo "Connected to database~! <br />"; echo "<b>Displaying details...</b> <br /><br />"; $query1 = "SELECT * FROM testing"; $result1 = mysql_query($query1) or die('cant select tables'); while($row = mysql_fetch_array($result1)) { echo $row['fn'] ."-". $row['ln'] ."-". $row['ff'] ."-". $row['fh'] ."-". $row['yb'] ."-". $row['mar']; echo "<br />"; } mysqli_close($dbc); ?> <a href="custom2.html">go back to steve's info form</a> Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984327 Share on other sites More sharing options...
bruceleejr Posted December 27, 2009 Author Share Posted December 27, 2009 bumped Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984589 Share on other sites More sharing options...
premiso Posted December 27, 2009 Share Posted December 27, 2009 You can test for just the dashes, or do not incorporate the dashes and separate it into 3 different fields and just combine the fields if they are not empty. Unable to really see what you are talking about as the site errors out to a checking for malicious content page. Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984625 Share on other sites More sharing options...
bruceleejr Posted December 28, 2009 Author Share Posted December 28, 2009 Okay how can I accomplish what your talking about~?? The site shouldnt have errors, it works perfectly fine from my end Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984631 Share on other sites More sharing options...
trq Posted December 28, 2009 Share Posted December 28, 2009 The site shouldnt have errors, it works perfectly fine from my end Again, your not selecting a database properly. Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-984662 Share on other sites More sharing options...
bruceleejr Posted December 29, 2009 Author Share Posted December 29, 2009 OKay fill this out here http://testo.comoj.com/stuff/custom4.html It'l get outputted to here http://testo.comoj.com/stuff/custom4.php Heres the code: <? $fn = $_POST["fn"]; $ln = $_POST['ln']; $ff = $_POST['ff']; $fh = $_POST['fh']; $yb = $_POST['yb']; $mar = $_POST['mar']; $dbc = mysqli_connect('mysql5.000webhost.com', 'a3393387_c2use', 'usmc72', 'a3393387_c2db') or die('Cant connect to MySQL servies~!!'); $query = "INSERT INTO testing (fn,ln, " . " ff, fh, yb, mar) " . " VALUES ('$fn', '$ln', '$ff', '$fh', '$yb', '$mar')"; $result = mysqli_query($dbc, $query) or die('error querying database'); mysql_connect('mysql5.000webhost.com', 'a3393387_c2use', 'usmc72') or die('error conecint'); echo "Connected to mysql~! <br />"; mysql_select_db('a3393387_c2db'); echo "Connected to database~! <br />"; echo "<b>Displaying details...</b> <br /><br />"; $query1 = "SELECT * FROM testing"; $result1 = mysql_query($query1) or die('cant select tables'); while($row = mysql_fetch_array($result1)) { echo $row['fn'] ."-". $row['ln'] ."-". $row['ff'] ."-". $row['fh'] ."-". $row['yb'] ."-". $row['mar']; echo "<br />"; } mysqli_close($dbc); ?> <a href="custom4.html">go back to steve's info form</a> If you refresh the page a new line of dashes will appear ABOVE the recently inserted data Quote Link to comment https://forums.phpfreaks.com/topic/186360-trying-to-retrieve-info-but-select-command-not-working/#findComment-985179 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.