...

View Full Version : I Need help!



kyleh55y
08-17-2011, 06:27 PM
Firstly, I am new to this website and appreciate your patience. I recently took over the running of my webpage from a professional to save money and have only so far caused my self so much stress....

I was wondering if there was a way to create a MySQL database and have my HTML site extract data from the database and display it on my site.

For Example:

Database will hold: Company name, Address and Contact Details...

using MySQL and PHP or something is there a way to display

Company
Address
Tel
Web

on my site?

Thanks in advance

Kyleh55y:confused:

guelphdad
08-17-2011, 07:14 PM
Yes there is. Do a web search on PHP, MySQL and web forms.

Note that saving money can often come with headaches particularly if you have no knowledge of how to do any programming.

kyleh55y
08-17-2011, 07:31 PM
Thank you for your help! Tell me about it i have one now. I know HTML and CSS but the rest bugs the hell out of me.

guelphdad
08-17-2011, 07:37 PM
I recently took over the running of my webpage from a professional to save money

Sounds like that may not have been the best decision then.

kyleh55y
08-17-2011, 07:39 PM
Yeah , on my site at the moment i have to manually type in every detail and i thought i could make it easier by inserting PHP or something even asp to import the data into my site from a database or excel speadsheet... I wish i could have learned this instead if HTML.

guelphdad
08-17-2011, 08:47 PM
HTML is like graduating Kindergarten, PHP/MySQL is like starting high school, not difficult by any means just further down the road in your education.

So you are either going to have to learn how to do it OR find someone to pay to get them to do it for you. But you've been down that road before and what you needed to get done didn't get done from the sounds of it.

kyleh55y
08-17-2011, 09:19 PM
Thats right, and i had to pay 100 to update it everytime i needed to add another piece of information! I was spending about 1000 a month just adding a few contact details to our customer page!

Old Pedant
08-18-2011, 12:38 AM
Well, you were probably being overcharged, but we can't tell that for sure from your description. I would think that for 1000 you could get a complete-forever-with-peanut-butter-and-pickles-on-it contact page.

You might want to look at the Web Projects forum here
http://www.codingforums.com/forumdisplay.php?f=47

kyleh55y
08-18-2011, 07:41 PM
ok,

I have my form connected to my SQL Database but when submitted it shows

"Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test','etsy','kjlk','njkln','nn;;l','nln;','lknnlkkl','lknlk'' at line 3

can anyone tell me what this means?

kyleh55y
08-18-2011, 08:30 PM
ok,

I have my form connected to my SQL Database but when submitted it shows

"Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test','etsy','kjlk','njkln','nn;;l','nln;','lknnlkkl','lknlk'' at line 3

can anyone tell me what this means?

Just thought you might need somemore details
''test','etsy','kjlk','njkln','nn;;l','nln;','lknnlkkl','lknlk'' are fake entries i placed in my form to test it.

The form is basic HTML/PHP as below

<form action="insert.php" method="post">

Section: <input type="text" name="section" /><br />
Company Name: <input type="text" name="companyname" />
<br />
Address Line 1: <input type="text" name="addressline1" />
<br />
Address Line 2: <input type="text" name="addressline2" />
<br />
Address Line 3: <input type="text" name="addressline3" />
<br />
Town: <input type="text" name="town" />
<br />
County: <input type="text" name="county" />
<br />
Postal Code: <input type="text" name="postcode" />
<br />
Tel: <input type="text" name="tel" />
<br />
Fax: <input type="text" name="fax" />
<br />
E-mail: <input type="text" name="email" />
<br />
Webpage: <input type="text" name="web" />
<br />
Submit to site: <input type="submit" />
</form>


and the insert.php is below

<?php
$con = mysql_connect("server","username","passport");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("n1stopadvertisercou_621555_db1", $con);

$sql="INSERT INTO Company (section, companyname, addressline1, addressline2, addressline3, town, county, postcode, tel, fax, email, web)
VALUES
('$_POST[section]','$_POST[companyname]','$_POST[addressline1]','$_POST[addressline2]'),'$_POST[addressline3]','$_POST[town]','$_POST[county]','$_POST[postcode]','$_POST[tel]','$_POST[fax]','$_POST[email]','$_POST[web]'";

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

mysql_close($con)
?>

I hope this helps!

Kyleh55y

Old Pedant
08-18-2011, 08:34 PM
Add one line of code:


$sql="INSERT INTO Company (section, companyname, addressline1, addressline2, addressline3, town, county, postcode, tel, fax, email, web)
VALUES
('$_POST[section]','$_POST[companyname]','$_POST[addressline1]','$_POST[addressline2]'),'$_POST[addressline3]','$_POST[town]','$_POST[county]','$_POST[postcode]','$_POST[tel]','$_POST[fax]','$_POST[email]','$_POST[web]'";

echo "<hr/>DEBUG SQL: " . $sql . "<hr/>";

Tell us what that DEBUG line shows you.

kyleh55y
08-18-2011, 08:43 PM
Could not connect:

I'm guessing that's my problem!

Old Pedant
08-18-2011, 09:04 PM
Yep. But if you have other pages that *CAN* connect, then clone their connection code.


$con = mysql_connect("server","username","passport");

You *do* realize that you need the *actual* name of the server in there, along with the *actual* username and password values?

kyleh55y
08-18-2011, 09:09 PM
yes thanks, I need to just figure out which server i put either "localhost" or server side host name

Thanks for your support you are very helpful!

kyleh55y
08-18-2011, 09:12 PM
Does it matter that its a 123-reg hosting and domain?

Old Pedant
08-18-2011, 09:16 PM
Yes, in the sense that it would matter in any case.

Whether the server is localhost or on another machine is up to the web host. MySQL can be installed on the same computer as the web server (in which case "localhost" should work) but it can also be installed on a completely separate server.

If you don't know the answer, you'll have to ask the hosting company.

But I say again: If you have ANY other pages where MySQL is working, just find the mysql_connect() call on them and clone it here.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum