View Full Version: endless loading

MPAM Rebooted Forums > Software support (freewares, PHP...) > endless loading


Title: endless loading
Description: php question


257335 - December 25, 2006 06:18 AM (GMT)
ok i finaly got my server all set up with php mysql ect and i started writing some php code in my website

<?php
$con = mysql_connect("localhost:8080");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("realestate", $con);

$sql="INSERT INTO estate (accountnum,address,zipcode,price,baths,bedrooms,state,city,squarefeet,county,subdivision,yearbuilt,
description,buyorlease,typeofprop,imagename,acreage)
VALUES
('$_POST[accountnum]','$_POST[Address]','$_POST[zipcode]','$_POST[price]','$_POST[baths]','$_POST[bedrooms]','$_POST[state]','$_POST[city]','$_POST[squarefeet]','$_POST[county]','$_POST[subdivision]','$_POST[yearbuilt]','$_POST[description]','$_POST[buyorlease]','$_POST[type]','$_POST[imagepath]','$_POST[acreage]')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con)
?>

when you click the submit button on another page it is sopost send post data to this file when you click submit. instead it just loaded and loads and loads

any idea on the problem?

patheticcockroach - December 25, 2006 07:55 AM (GMT)
QUOTE
$con = mysql_connect("localhost:8080");

Did you really set up MySQL to listen port 8080 ? The syntax is pretty unusual too. Usually you also add your username and password. Personnally I never precise the port since I left the default one.
So on my website I use
CODE
@mysql_connect($db_host,$db_user,$db_pass) or header("Location: http://www.patheticcockroach.com/down.htm");


Otherwise, your script seems ok except that it's very unsercure. Don't you get any error message ?

257335 - December 26, 2006 08:34 PM (GMT)
ok i didnt realize that when is sayed server name it ment the sql server so i took off the 8080 and i got this

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in C:\Documents and Settings\Marquis Taliaferro\Desktop\web page\fromCMS.php on line 2
Could not connect: Can't connect to MySQL server on 'localhost' (10061)

ps yes i know the code has alot of holes in it but its my first shot at php and im just trying to get it to work.

patheticcockroach - December 26, 2006 09:11 PM (GMT)
Well it looks like either your MySQL server isn't running, or your username and password for MySQL are wrong or you touched the default MySQL ports (in the tutorial I leave all default ports for MySQL (in MySQL configuration and in php.ini).
Is phpmyadmin working fine ?

257335 - December 28, 2006 09:15 PM (GMT)
yes i had the mysql server no and phpmyadmin is working i know i have my password is right but im not sure about my username how would i check that

patheticcockroach - December 29, 2006 06:41 AM (GMT)
Your MySQL username is very probably "root". You can create/edit accounts in phpMyAdmin by clicking on Privileges (4th link from bottom on first page).

257335 - December 29, 2006 08:54 AM (GMT)
yes this fixed it it works fine now thanks

257335 - December 29, 2006 10:17 PM (GMT)
ok im having another problem
im getting this error
Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Documents and Settings\Marquis Taliaferro\Desktop\web page\results.php on line 38

here is the php code
$result = mysql_query("SELECT * FROM estate
WHERE city='$_GET["city"]'
//AND where state='$_GET["state"]'
//AND where zipcode='$_GET["zipcode"]'
//AND where price='$_GET["price"]'
//AND where baths='$_GET["baths"]'
//AND where bedrooms='$_GET["bedrooms"]'
//AND where county='$_GET["county"]'
//AND where buyorlease='$_GET["buyorlease"]'
");

here it the html code
<form name="input" action="results.php" method="get">

City:<input type="text" name="city" size="30"><br><br>


<input type="submit" value="Submit">

</form>

patheticcockroach - December 30, 2006 06:36 AM (GMT)
Try
CODE
$result = mysql_query("SELECT * FROM estate
WHERE city='".$_GET["city"]."'
//AND where state='$_GET["state"]'
//AND where zipcode='$_GET["zipcode"]'
//AND where price='$_GET["price"]'
//AND where baths='$_GET["baths"]'
//AND where bedrooms='$_GET["bedrooms"]'
//AND where county='$_GET["county"]'
//AND where buyorlease='$_GET["buyorlease"]'
");

And note that to add other conditions you shouldn't repeat "where"
CODE
$result = mysql_query("SELECT * FROM estate
WHERE (city='".$_GET["city"]."'
AND state='".$_GET["state"]."')
");

257335 - December 30, 2006 07:00 AM (GMT)
all this did was make the error on line 39 instead of 38

Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Documents and Settings\Marquis Taliaferro\Desktop\web page\results.php on line 39

257335 - December 30, 2006 07:07 AM (GMT)
delete that last post when i did this is sayed this
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\Marquis Taliaferro\Desktop\web page\results.php on line 48

here is the code where i used that

while($row = mysql_fetch_array($result))
{
echo $row['city'];
}


?>



257335 - December 30, 2006 07:15 AM (GMT)
ok i fixed that with while($row = @mysql_fetch_array($result))
{
echo $row['city'];
}


?>
but it doesnt display anything


patheticcockroach - December 30, 2006 07:58 AM (GMT)
The @ doesn't fix anything, it just prevents errors from being displayed. Please post your full code it will be much easier (don't forget to remove your DB password ;) )

257335 - December 30, 2006 08:11 AM (GMT)
me and my friend fixed it for some reason is was having a problem with the comments
$result = mysql_query("SELECT * FROM estate
WHERE city='".$_GET["city"]."'
//AND where state='$_GET["state"]'
//AND where zipcode='$_GET["zipcode"]'
//AND where price='$_GET["price"]'
//AND where baths='$_GET["baths"]'
//AND where bedrooms='$_GET["bedrooms"]'
//AND where county='$_GET["county"]'
//AND where buyorlease='$_GET["buyorlease"]'
");
i just delete them and it worked "wierd"

257335 - December 30, 2006 08:27 PM (GMT)
ok need some more help

CODE


<html>
<head>
<title>Retail</title>
<link rel="stylesheet" href="CSS.css" type="text/css" />
</head>
<body>

<div id="sidebar">
<img src="images/bigdoglogo.gif" width="215"height="75">
<div id="menu">
<a href="Home.html">Home</a>
<a href="Apartments.html">Apartments</a>
<a href="Industrial.html">Industrial</a>
<a href="Land.html">Land</a>
<a class="active" href="Retail.html">Retail</a>
<a href="OfficeSpace.html">Office Space</a>
<a href="AboutUs.html">About Us</a>
</div>
</div>

<div id="content">
<h1>RETAIL! </h1>
<br>
<br>
<?php

$con = mysql_connect("localhost","root","*****");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }


mysql_select_db("realestate", $con);

$result = mysql_query("SELECT * FROM estate
WHERE type='retail'");

echo "<table border='1'>
<tr>
<th>Address</th>
<th>Price</th>
<th>Baths</th>
<th>Bedrooms</th>
<th>State</th>
<th>City</th>
<th>Square Feet</th>
<th>County</th>
<th>Year Built</th>
<th>Description</th>
<th>Buy or Lease</th>
</tr>";

while($row =  mysql_fetch_array($result))
 {
 echo "<tr>";
 echo "<td>" . $row['Address'] . "</td>";
 echo "<td>" . $row['Price'] . "</td>";
 echo "<td>" . $row['Baths'] . "</td>";
 echo "<td>" . $row['Bedrooms'] . "</td>";
 echo "<td>" . $row['State'] . "</td>";
 echo "<td>" . $row['City'] . "</td>";
 echo "<td>" . $row['Squareft'] . "</td>";
 echo "<td>" . $row['County'] . "</td>";
 echo "<td>" . $row['YearBuilt'] . "</td>";
 echo "<td>" . $row['Description'] . "</td>";
 echo "<td>" . $row['BuyorLease'] . "</td>";
 echo "</tr>";
 }
echo "</table>";

mysql_close($con);


?>

</body>
</html>

im trying to out put the result of my sql quiery in an table but im geting this
QUOTE

Address Price Baths Bedrooms State City Square Feet County Year Built Description Buy or Lease "; while($row = mysql_fetch_array($result)) { echo ""; echo "" . $row['Address'] . ""; echo "" . $row['Price'] . ""; echo "" . $row['Baths'] . ""; echo "" . $row['Bedrooms'] . ""; echo "" . $row['State'] . ""; echo "" . $row['City'] . ""; echo "" . $row['Squareft'] . ""; echo "" . $row['County'] . ""; echo "" . $row['YearBuilt'] . ""; echo "" . $row['Description'] . ""; echo "" . $row['BuyorLease'] . ""; echo ""; } echo ""; mysql_close($con); ?>

257335 - December 30, 2006 11:57 PM (GMT)
yea i started a new topic for this part since it as kinda getting off topic




Hosted for free by InvisionFree