Jump to content

trying to retrieve info but SELECT command not working


Recommended Posts

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

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~??

<?
$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>

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.