Current location: Hot Scripts Forums » Programming Languages » PHP » I need help


I need help

Reply
  #1 (permalink)  
Old 02-04-04, 11:56 AM
phpnewbie770 phpnewbie770 is offline
New Member
 
Join Date: Feb 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I need help

I have a script that I think is correct but I cannot connect to my database.

I am using godaddy.com as a server and also freesql.org

I was told that the phpMyAdmin in godaddy doesnt allow me to set up for connection so I tried freesql to test it on another server.

Presently, neither are working.

Can someone send me a sample connection script? Or check mine out? I removed the un/pw/server for obvious reasons.

My script looks like this...

<?php

// ---------------------------
//
// ---------------------------


$serveur = "server";
$utilisateur = "un";
$motDePasse = "pw";
$base = "db";

mysql_pconnect($serveur)
or die("Cannot connect.");
mysql_select_db($base)
or die("Database not found.");



$bname = $_POST["bname"];
$pname = $_POST["pname"];
$credentials = $_POST["credentials"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$phone = $_POST["phone"];
$fax = $_POST["fax"];
$website = $_POST["website"];
$email = $_POST["email"];
$mod1 = $_POST["mod1"];
$mod2 = $_POST["mod2"];
$mod3 = $_POST["mod3"];
$mod4 = $_POST["mod4"];
$mod5 = $_POST["mod5"];
$prod1 = $_POST["prod1"];
$prod2 = $_POST["prod2"];
$prod3 = $_POST["prod3"];



$dt = date("U");

// Quotes issue


$bname = str_replace ( "'", "''", $bname );
$pname = str_replace ( "'", "''", $pname );
$credentials = str_replace ( "'", "''", $credentials );
$address = str_replace ( "'", "''", $address );
$city = str_replace ( "'", "''", $city );
$state = str_replace ( "'", "''", $state );
$zip = str_replace ( "'", "''", $zip );
$phone = str_replace ( "'", "''", $phone );
$fax = str_replace ( "'", "''", $fax );
$website = str_replace ( "'", "''", $website );
$email = str_replace ( "'", "''", $email );
$mod1 = str_replace ( "'", "''", $mod1 );
$mod2 = str_replace ( "'", "''", $mod2 );
$mod3 = str_replace ( "'", "''", $mod3 );
$mod4 = str_replace ( "'", "''", $mod4 );
$mod5 = str_replace ( "'", "''", $mod5 );
$prod1 = str_replace ( "'", "''", $prod1 );
$prod2 = str_replace ( "'", "''", $prod2 );
$prod3 = str_replace ( "'", "''", $prod3 );



mysql_query("INSERT INTO nhp (bname,pname,credentials,address,city,state,zip,ph one,fax,website,email,modalitycode1,modalitycode2, modalitycode3,modalitycode4,modalitycode5,featured product1,featuredproduct2,featuredproduct3,other)" .
" VALUES (

'$bname', '$pname', '$credentials', '$address','$city', '$state', '$zip', '$phone', '$fax', '$website', '$email', '$mod1', '$mod2', '$mod3', '$mod4', '$mod5', '$prod1', '$prod2', '$prod3', 'x' ) ")

or die("<font color=\"#FF0000\">Unable to add this field !");




// -----------------------------------------------------------

print( "<center>");
print( "<b><font color=\"#000000\">Field added.<BR>");
print( "<A HREF=\"submit.php\"><B><FONT FACE=\"Arial,Helvetica,Univers,Zurich BT\"> ");
print(" Click here to add a new field</FONT></B></A>");
print( "</font></b><br>");
print( "<A HREF=\"kapsi_search_submit.php\"><B><FONT FACE=\"Arial,Helvetica,Univers,Zurich BT\"> ");
print(" Click here to search a row</FONT></B></A>");
print( "</font></b><br>");




?>
Reply With Quote
  #2 (permalink)  
Old 02-04-04, 11:59 AM
Merovingian's Avatar
Merovingian Merovingian is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Los Angeles
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
What seems to be the problem ?

So you are not connecting to the freesql.org Database?


Quote:
Originally Posted by phpnewbie770
I have a script that I think is correct but I cannot connect to my database.

I am using godaddy.com as a server and also freesql.org

I was told that the phpMyAdmin in godaddy doesnt allow me to set up for connection so I tried freesql to test it on another server.

Presently, neither are working.

Can someone send me a sample connection script? Or check mine out? I removed the un/pw/server for obvious reasons.

My script looks like this...

<?php

// ---------------------------
//
// ---------------------------


$serveur = "server";
$utilisateur = "un";
$motDePasse = "pw";
$base = "db";

mysql_pconnect($serveur)
or die("Cannot connect.");
mysql_select_db($base)
or die("Database not found.");



$bname = $_POST["bname"];
$pname = $_POST["pname"];
$credentials = $_POST["credentials"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$phone = $_POST["phone"];
$fax = $_POST["fax"];
$website = $_POST["website"];
$email = $_POST["email"];
$mod1 = $_POST["mod1"];
$mod2 = $_POST["mod2"];
$mod3 = $_POST["mod3"];
$mod4 = $_POST["mod4"];
$mod5 = $_POST["mod5"];
$prod1 = $_POST["prod1"];
$prod2 = $_POST["prod2"];
$prod3 = $_POST["prod3"];



$dt = date("U");

// Quotes issue


$bname = str_replace ( "'", "''", $bname );
$pname = str_replace ( "'", "''", $pname );
$credentials = str_replace ( "'", "''", $credentials );
$address = str_replace ( "'", "''", $address );
$city = str_replace ( "'", "''", $city );
$state = str_replace ( "'", "''", $state );
$zip = str_replace ( "'", "''", $zip );
$phone = str_replace ( "'", "''", $phone );
$fax = str_replace ( "'", "''", $fax );
$website = str_replace ( "'", "''", $website );
$email = str_replace ( "'", "''", $email );
$mod1 = str_replace ( "'", "''", $mod1 );
$mod2 = str_replace ( "'", "''", $mod2 );
$mod3 = str_replace ( "'", "''", $mod3 );
$mod4 = str_replace ( "'", "''", $mod4 );
$mod5 = str_replace ( "'", "''", $mod5 );
$prod1 = str_replace ( "'", "''", $prod1 );
$prod2 = str_replace ( "'", "''", $prod2 );
$prod3 = str_replace ( "'", "''", $prod3 );



mysql_query("INSERT INTO nhp (bname,pname,credentials,address,city,state,zip,ph one,fax,website,email,modalitycode1,modalitycode2, modalitycode3,modalitycode4,modalitycode5,featured product1,featuredproduct2,featuredproduct3,other)" .
" VALUES (

'$bname', '$pname', '$credentials', '$address','$city', '$state', '$zip', '$phone', '$fax', '$website', '$email', '$mod1', '$mod2', '$mod3', '$mod4', '$mod5', '$prod1', '$prod2', '$prod3', 'x' ) ")

or die("<font color=\"#FF0000\">Unable to add this field !");




// -----------------------------------------------------------

print( "<center>");
print( "<b><font color=\"#000000\">Field added.<BR>");
print( "<A HREF=\"submit.php\"><B><FONT FACE=\"Arial,Helvetica,Univers,Zurich BT\"> ");
print(" Click here to add a new field</FONT></B></A>");
print( "</font></b><br>");
print( "<A HREF=\"kapsi_search_submit.php\"><B><FONT FACE=\"Arial,Helvetica,Univers,Zurich BT\"> ");
print(" Click here to search a row</FONT></B></A>");
print( "</font></b><br>");




?>
__________________
"Duo seguere aut de via decede" ...
Reply With Quote
  #3 (permalink)  
Old 02-04-04, 12:07 PM
soubriquet soubriquet is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by phpnewbie770
I have a script that I think is correct but I cannot connect to my database.

I am using godaddy.com as a server and also freesql.org

I was told that the phpMyAdmin in godaddy doesnt allow me to set up for connection so I tried freesql to test it on another server.

Presently, neither are working.

Can someone send me a sample connection script? Or check mine out? I removed the un/pw/server for obvious reasons.

My script looks like this...

<?php

// ---------------------------
//
// ---------------------------


$serveur = "server";
$utilisateur = "un";
$motDePasse = "pw";
$base = "db";

mysql_pconnect($serveur)
or die("Cannot connect.");
mysql_select_db($base)
or die("Database not found.");



$bname = $_POST["bname"];
$pname = $_POST["pname"];
$credentials = $_POST["credentials"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$phone = $_POST["phone"];
$fax = $_POST["fax"];
$website = $_POST["website"];
$email = $_POST["email"];
$mod1 = $_POST["mod1"];
$mod2 = $_POST["mod2"];
$mod3 = $_POST["mod3"];
$mod4 = $_POST["mod4"];
$mod5 = $_POST["mod5"];
$prod1 = $_POST["prod1"];
$prod2 = $_POST["prod2"];
$prod3 = $_POST["prod3"];



$dt = date("U");

// Quotes issue


$bname = str_replace ( "'", "''", $bname );
$pname = str_replace ( "'", "''", $pname );
$credentials = str_replace ( "'", "''", $credentials );
$address = str_replace ( "'", "''", $address );
$city = str_replace ( "'", "''", $city );
$state = str_replace ( "'", "''", $state );
$zip = str_replace ( "'", "''", $zip );
$phone = str_replace ( "'", "''", $phone );
$fax = str_replace ( "'", "''", $fax );
$website = str_replace ( "'", "''", $website );
$email = str_replace ( "'", "''", $email );
$mod1 = str_replace ( "'", "''", $mod1 );
$mod2 = str_replace ( "'", "''", $mod2 );
$mod3 = str_replace ( "'", "''", $mod3 );
$mod4 = str_replace ( "'", "''", $mod4 );
$mod5 = str_replace ( "'", "''", $mod5 );
$prod1 = str_replace ( "'", "''", $prod1 );
$prod2 = str_replace ( "'", "''", $prod2 );
$prod3 = str_replace ( "'", "''", $prod3 );



mysql_query("INSERT INTO nhp (bname,pname,credentials,address,city,state,zip,ph one,fax,website,email,modalitycode1,modalitycode2, modalitycode3,modalitycode4,modalitycode5,featured product1,featuredproduct2,featuredproduct3,other)" .
" VALUES (

'$bname', '$pname', '$credentials', '$address','$city', '$state', '$zip', '$phone', '$fax', '$website', '$email', '$mod1', '$mod2', '$mod3', '$mod4', '$mod5', '$prod1', '$prod2', '$prod3', 'x' ) ")

or die("<font color=\"#FF0000\">Unable to add this field !");




// -----------------------------------------------------------

print( "<center>");
print( "<b><font color=\"#000000\">Field added.<BR>");
print( "<A HREF=\"submit.php\"><B><FONT FACE=\"Arial,Helvetica,Univers,Zurich BT\"> ");
print(" Click here to add a new field</FONT></B></A>");
print( "</font></b><br>");
print( "<A HREF=\"kapsi_search_submit.php\"><B><FONT FACE=\"Arial,Helvetica,Univers,Zurich BT\"> ");
print(" Click here to search a row</FONT></B></A>");
print( "</font></b><br>");




?>



================================================== ===

why not just try something simple like

$db = mysql_connect("yourhostname or IP", "login", "password");

mysql_select_db("name of database",$db);

and test retrieving just one thing to get it working?
Reply With Quote
  #4 (permalink)  
Old 02-04-04, 12:17 PM
phpnewbie770 phpnewbie770 is offline
New Member
 
Join Date: Feb 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
First of all I want to say Thank YOU for replying....in all the message boards I've tried no one is even trying.

Second...I tried. It didnt work.

If you want to see what I am doing go to holistichealthpro.com and click SEARCH A PROFESSIONAL and try it.

I have tried using phpmaker to generate scripts but they are not what I want ALTHOUGH i can connect to both my freesql and go daddy databases through PHPMAKER program.

Seems odd.

Thanks for any help!
Reply With Quote
  #5 (permalink)  
Old 02-04-04, 12:31 PM
soubriquet soubriquet is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by phpnewbie770
First of all I want to say Thank YOU for replying....in all the message boards I've tried no one is even trying.

Second...I tried. It didnt work.

If you want to see what I am doing go to holistichealthpro.com and click SEARCH A PROFESSIONAL and try it.

I have tried using phpmaker to generate scripts but they are not what I want ALTHOUGH i can connect to both my freesql and go daddy databases through PHPMAKER program.

Seems odd.

Thanks for any help!
================================================== ====

not really familiar with these programs but it probably isn't a script problem. Do you have Telnet/SSH access to the server? this would be the only way to really check otherwise you will need to harrass the ISP and get them check it for you. Could be any number of things.
Reply With Quote
  #6 (permalink)  
Old 02-04-04, 12:50 PM
soubriquet soubriquet is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by soubriquet
================================================== ====

not really familiar with these programs but it probably isn't a script problem. Do you have Telnet/SSH access to the server? this would be the only way to really check otherwise you will need to harrass the ISP and get them check it for you. Could be any number of things.
try this

<html>

<body>



<?php

phpinfo();

?>



</body>

</html>

will tell you whether sql is available etc..
Reply With Quote
  #7 (permalink)  
Old 02-04-04, 01:37 PM
phpnewbie770 phpnewbie770 is offline
New Member
 
Join Date: Feb 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
WElll....that didnt tell me anything...I came up with a blank page.

PHP/MySQL are SUPPOSED to be available with the hosting plan I got. I talked to support, but they are no help.

They say everything is working fine and it seems so odd because I can connect other ways just not through my site.

ARRGGHH!!

Thanks for the advice though!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 08:16 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.