Jump to content

tvtg

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tvtg's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I want to keep "mysql_connect" result in a global that can be used by few scripts I have a file DBActivities.php which contains many functions that access my sql and run some queries so the file looks like that: <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = ''; connect() { global $conn = mysql_connect($dbhost, $dbuser, $dbpass) or ...... } f1() { run some query using conn as global } f2() { run some query using conn as global } ?> when my main page is loaded I call connect with success meaning conn is now contains the DB connect result now I have a second php file Stuff.php <?php include DBActivities.php; f1(); f2(); ?> I assumed that conn is global and was initated then when calling to f1 and f2 conn keeps the information How do I maintain conn without keep connecting to the DB for every query Thanks in advance T.
  2. Hi, Im total new in PHP and HTMl programming - any help will be welcome What Im trying to do is I have a main.html file with form on the form there is one button and the code is as follow: <INPUT type="button" class="buttons" value="Add Stuff" onClick="window.open('AddStuff.php','New Stuff', 'width=100%,height=100%')"> Now what I want to happen is that AddStuff.php will contain both html form and php code that will validate Form fields before inserting the values to MySQL My problem is how the php file should be build is it : <?php do some PHP validations here and if OK send to the SQL DB > <html> <head> head stuff </head> <body> <form name="newStuff" action="AddStuff.php" method="post" onSubmit="return validateNewStuffForm()"> ...form stufff .... </form> </body> </html> if I put it this way the php stuff is called also when I open the window Please help in how to arange the php file in a way that : 1) html file will be opened 2) form will be filled 3) php procedures on the same file will called 4) How do I close the window when php procedures were done successfully Thanks in advance for all your help T
×
×
  • 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.