954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problems with first php file



">

Please enter the name of the business:

Please enter the phone number of the business:

Please enter the primary key:

Please enter the image location where the business image is stored:

<?php
$user = "peilife_admin";
$host = "localhost";
$password = "*******";
$database = "peilife_busdir"


$connection = mysql_connect($host, $user, $password) or die ("Could not make connection to server");
**line 32**mysql_select_db ('peilife_admin') or die ("Couldn't select database");

$query1 = "INSERT INTO name(busname) VALUES ($busname)"
$query2 = "INSERT INTO phone(busphone) VALUES ($busphone)"
$query3 = "INSERT INTO primary(primkey) VALUES ($primkey)"
$query4 = "INSERT INTO images(imageloc) VALUES ($imageloc)"

$result1 = mysql_query($query1);
$result2 = mysql_query($query2);
$result3 = mysql_query($query3);
$result4 = mysql_query($query4);

echo "Record updated";

?>

andyseaton2003
Newbie Poster
4 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

$database = "peilife_busdir"

That line requires an ; (semicolon) at the end of it.

As do these lines..

$query1 = "INSERT INTO name(busname) VALUES ($busname)"
$query2 = "INSERT INTO phone(busphone) VALUES ($busphone)"
$query3 = "INSERT INTO primary(primkey) VALUES ($primkey)"
$query4 = "INSERT INTO images(imageloc) VALUES ($imageloc)"

Also line:

">

shouldnt have the additional "> at the end of it...

ReDuX
Junior Poster
127 posts since Sep 2004
Reputation Points: 12
Solved Threads: 5
 

Thanks for the help mate, but that didn't seem to fix it. Any other suggestions? I'm still checking on it.

Thanks

Andy

andyseaton2003
Newbie Poster
4 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

In the line:

mysql_select_db ('peilife_admin') or die ("Couldn't select database");

You are selecting a database with named after your username, not the database name..

Should it not be:

mysql_select_db ('peilife_busdir') or die ("Couldn't select database");

?

ReDuX
Junior Poster
127 posts since Sep 2004
Reputation Points: 12
Solved Threads: 5
 

[PHP]$query1 = "INSERT INTO name(busname) VALUES ($busname)";
$query2 = "INSERT INTO phone(busphone) VALUES ($busphone)";
$query3 = "INSERT INTO primary(primkey) VALUES ($primkey)";
$query4 = "INSERT INTO images(imageloc) VALUES ($imageloc)";[/PHP]

Make sure to put single quote if $busname, $busphone, $primkey and $imageloc are varchar type in mysql.

Hope it helps.

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

Sorry guys, none of these suggestions has helped - if I comment out the offending line it just tells me the first line of php code is wrong - where I set the user. I can't figure this - its just not willing to run it.

Thanks for any help.

Andy

andyseaton2003
Newbie Poster
4 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

<?php

echo "

Please enter the name of the business:

Please enter the phone number of the business:

Please enter the primary key:

Please enter the image location where the business image is stored:


";

if ($submit=="submit"){ //$reset = reset type name and $ submit = submit type name

$user = "peilife_admin";
$host = "localhost";
$password = "*******";
$database = "peilife_busdir";
//if (!($connection = mysql_connect("localhost","","")))
if (!($connection = mysql_connect($user,$host,$password)))
{
print "could not connect to database\n";
exit;
}

//$connection = mysql_connect($host, $user, $password) or die ("Could not make connection to server");
mysql_select_db ('peilife_admin') or die ("Couldn't select database");

$query1 = "INSERT INTO name(busname) VALUES ('$busname')";
$query2 = "INSERT INTO phone(busphone) VALUES ('$busphone')";
$query3 = "INSERT INTO primary(primkey) VALUES ('$primkey')";
$query4 = "INSERT INTO images(imageloc) VALUES ('$imageloc')";

$result1 = mysql_query($query1);
$result2 = mysql_query($query2);
$result3 = mysql_query($query3);
$result4 = mysql_query($query4);

echo "Record updated";
}
?>

billah_norm
Light Poster
25 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You