Jump to content

fogofogo

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by fogofogo

  1. Hello I' having problems called a mssql stored proc with the following code... $myServer = "SERVER"; $myUser = "USER"; $myPass = "PASS"; $myDB = "DB"; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); // call my proc fromhere function loginUser($alias, $password) { $proc = mssql_init('sp_CheckUserExists',$selected); mssql_bind($proc,'@Alias',$alias,SQLVARCHAR); mssql_bind($proc,'@Password',$password,SQLVARCHAR); if ($result = mssql_execute($proc)) { if ($row = mssql_fetch_row($result)) { // action } } And here are the erros I am getting.... Warning: mssql_init(): supplied argument is not a valid MS SQL-Link resource in Functions.php on line 70 Warning: mssql_bind(): supplied argument is not a valid MS SQL-Statement resource in Functions.php on line 72 Warning: mssql_execute(): supplied argument is not a valid MS SQL-Statement resource in Functions.php on lin Anyone know what theses errors are? THanks!
  2. looks like I messed it up. This fixed it CREATE PROCEDURE LoginUsers(IN palias VARCHAR(30), OUT pFirstName VARCHAR(30)) BEGIN SELECT FirstName INTO pFirstName FROM users WHERE Alias=palias; END
  3. Hello, I'm trying to create a stored procedure through phpmyadmin and its giving me an error. Heres my query... DROP PROCEDURE IF EXISTS `LoginUser` GO CREATE PROCEDURE LoginUser( IN p_Alias varchar(30) ) BEGIN SELECT FirstName FROM users WHERE Alias = p_Alias; END GO Its giving me an error saying ... check the manual that corresponds to your MySQL server version for the right syntax to use near 'GO Can anyone see the obvious error I'm making? Sorry I'm new to this. Cheers
  4. Thats right - sorry I should have said. It is an xml response. I'm take a look at this DOM business. Thanks!
  5. Hello all I am having a bit of trouble selecting a value from xml. The format of the xml is like this <newplayer> <transaction result="OK"/> <username>Jimbo</username> </newplayer> I am able to print out the value between the username nodes. I just cant figure out how to check what the falue is for result in transaction. I am using this code at the moment... function sendRegistrationPlaytech($URLString) { $url = "https://newplayer.php?" . $URLString; $ch = curl_init(); // set curl options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, 1); //curl_setopt ($ch, CURLOPT_POSTFIELDS, $form); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $content = curl_exec ($ch); # This returns HTML curl_close ($ch); return $content; } Any help would be great Thanks
  6. not sure if it is - I thought FOR is a reserved name? I could be wrong. anyone know if this is the problem?
  7. Hello All, I have a script that displays and allows users to edit records in a mysql database. It displays the information correctly, but when I try to edit the information through forms I have created,  it gives me the "successful" message, but makes no changes to the database. I have printed out the sql, which looks like this... UPDATE division_1 SET Team='Dundee', Played='2', Won='3', Lost='4', Drawn='3', [For]='12', Against='5', Points='12' WHERE ID=2 and heres what the sql in the code looks like... UPDATE division_1 SET Team='".$Team."', Played='$Played', Won='$Won', Lost='$Lost', Drawn='$Drawn', [For]='$For', Against='$Against', Points='$Points' WHERE ID=".$id; theres probably blinding errors - I'm fairly new to this. Heres my code that inserts it into the database (sorry its a mess) - [CODE] <?php $host = "localhost"; $user = "root"; $passw="password"; $db = "millhill"; $connection = @mysql_connect($host, $user) or die (mysql_error()); mysql_select_db($db, $connection) or die (mysql_error()); $id = $_GET['id']; $Team = $_POST['Team']; $Played = $_POST['Played']; $Won = $_POST['Won']; $Lost = $_POST['Lost']; $Drawn = $_POST['Drawn']; $For = $_POST['For']; $Against = $_POST['Against']; $Points = $_POST['Points']; $submit = $_POST['submit']; if ($id) {   if ($submit) {     $sql = "UPDATE division_1 SET Team='".$Team."', Played='$Played', Won='$Won', Lost='$Lost', Drawn='$Drawn', [For]='$For', Against='$Against', Points='$Points' WHERE ID=".$id; echo $sql;     $result = mysql_query($sql); echo $result;     echo "Thank you! Information updated.\n";   } else {     // query the DB     $sql = "SELECT * FROM division_1 WHERE id=$id";     $result = mysql_query($sql);     $myrow = mysql_fetch_array($result);     ?>     <form method="post" action="<?php echo $PHP_SELF?>">     <input type=hidden name="id" value="<?php echo $myrow["ID"] ?>">     Team:<input type="Text" name="Team" value="<?php echo $myrow["Team"] ?>"><br>     Played<input type="Text" name="Played" value="<?php echo $myrow["Played"] ?>"><br>     Lost<input type="Text" name="Lost" value="<?php echo $myrow["Lost"] ?>"><br> Won:<input type="Text" name="Won" value="<?php echo $myrow["Won"] ?>"><br>     Drawn:<input type="Text" name="Drawn" value="<?php echo $myrow["Drawn"] ?>"><br> For:<input type="Text" name="For" value="<?php echo $myrow["For"] ?>"><br> Against:<input type="Text" name="Against" value="<?php echo $myrow["Against"] ?>"><br> Points:<input type="Text" name="Points" value="<?php echo $myrow["Points"] ?>"><br>     <input type="Submit" name="submit" value="Enter information">     </form> <?php } } else {   // display list of employees   $result = mysql_query("SELECT * FROM division_1",$connection );   while ($myrow = mysql_fetch_array($result)) {     printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["ID"], $myrow["Team"], $myrow["Played"]);   } } [/CODE] any ideas what I'm doing wrong? Cheers
  8. fixed it - if anyone would like to see the code: [code]<?php // print out the month that has been choosen $month = $_POST['date']; echo $month; include("db.php"); // select the ddate //echo "SELECT * FROM  pokercredit WHERE DATE_FORMAT(ddate, '%Y %M')='.$month; $query = mysql_query("SELECT * FROM  pokercredit WHERE DATE_FORMAT(ddate, '%Y %M')='".$month."'"); // print out the records while ($row = mysql_fetch_array($query)){ echo "$row[ID] $row[dfrom] $row[damount]<br>";     // name class and mark will be printed with one line break at the end } ?>[/code] it might be messy, but it works!
  9. Hi folks, I have a form that submits a date in this format : June 2006, and I am trying to use it to select records in a mysql database, that stores the date in this format: 2006-06-01. So I must change June 2006 into 2006-06-01 and then feed it into the feed the date into the SQL statement - right?? This is the part I am stuck on. some thing like this? $formattedDate = date("F Y", strtotime($month)); my code so far (which is probably way off), looks like this... [code]<?php // print out the month that has been choosen $month = $_POST['date']; echo $month; //$formattedDate = date("F Y", strtotime($month)); ... database stuff ... $query = mysql_query("SELECT DISTINCT ddate, DATE_FORMAT(ddate, '%Y %M')  ID FROM pokercredit"); // print out the records while ($row = mysql_fetch_array($query)){ echo "$row[ID] $row[dfrom] $row[damount]<br>";     // name class and mark will be printed with one line break at the end } ?>[/code] I'm obviously way off but any advice would be great, as I'm totally stuck on this. Thanks all J
  10. [!--quoteo(post=379038:date=Jun 1 2006, 07:14 AM:name=MikoMak)--][div class=\'quotetop\']QUOTE(MikoMak @ Jun 1 2006, 07:14 AM) [snapback]379038[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi, you probably want to use the mysql function date_format() to pull out just the month from the table e.g. something like $sql_date = mysql_query("SELECT date_format(ddate, '%M ') as ddate FROM casinocredit ") This will give you just the months by name and not the full date. (use '%M %Y' if you need the month and year e.g. May 2006 ) hth. [/quote] Thats cool - cheers Miko
  11. Hello all, I am trying to populate a drop down menu with a mysql database. I was hoping to have a selection of months in the dropdown menu, based on date fields in my database (displayed like january, february, march, april, ,may etc) when a user then selects a month, they will be brought to a new page that will have only the records created in that month. But in my database, the date is stored in this format: 2006-05-12 00:00:00 Is there any way that I could replace the dates with the months? for example : 2006 - 05, would be May 2006. if you need to see my code, here it is: [code]<? //database connection $query = mysql_query("SELECT * FROM casinocredit"); // start to print out the form echo "<form action=\"cats.php\" method=\"POST\"><select name=\"clients\"><option value=\"\" \"selected\">Select A Client</option>"; // loop through the records while ($row = mysql_fetch_array($query)) { echo "<option value=\"{$row['ID']}\">{$row['ddate']}</option>"; } echo "</select>"; echo "<input type=\"submit\" value=\"Go\"></form>"; ?>[/code] Anyone have any advice or opinions? Thanks for your time J[code][/code]
  12. [!--quoteo(post=379007:date=Jun 1 2006, 04:45 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 1 2006, 04:45 AM) [snapback]379007[/snapback][/div][div class=\'quotemain\'][!--quotec--] Can't say that I have, but I'd guess the harder thing to figure out would be the logic behind calculating the odds. Once you know how to do that, scripting it in PHP should be easy, I'm confident that it could be done with basic coding methods. [/quote] I should have given more info - sorry! I actually already have formulas worked out using excel - but I think the php will be a little bit beyond me. I think I might leave it, thanks anyway!
  13. Hi Folks - anyone ever come across a poker odds calculator tutortial, built with php? Cheers J
  14. Hello all, I was wondering if anyone had ever come across a php/mysql tutorial that shows how to create a cms that allows users to also upload and display images? Thanks J
  15. [!--quoteo(post=374939:date=May 18 2006, 08:40 AM:name=anatak)--][div class=\'quotetop\']QUOTE(anatak @ May 18 2006, 08:40 AM) [snapback]374939[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hello, I just want to say something about having a boolean on the record for hiding/showing. imagine you have more than one user accessing your database user 01 makes a selection and hides records 1 and 3 and 5 user 02 makes a selection but the records 1 and 3 and 5 are hidden so maybe he does not see the results he wanted. just a thought. to hide the records you have to run an UPDATE statement for every record. something like you make your checkbox in your form like this [code] <input name='record[$id]' type='checkbox' value='$id'> [/code] and where you process your form you do something like this [code] foreach ($_POST['record'] as $id => $val) { UPDATE STATEMENT; UPATE [table] set [name of boolean column]=1 where [name of idcolumn]=$id; } [/code] hope this helps [/quote] Thats brilliant - thanks
  16. [!--quoteo(post=374926:date=May 18 2006, 07:33 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 18 2006, 07:33 AM) [snapback]374926[/snapback][/div][div class=\'quotemain\'][!--quotec--] Are you deleting the record or just removing it from the display? If you're deleting the record from the database, you don't need an extra field. If you're just removing it from the display, all you need is an enum field that can be either 1 or 0. Keep in mind that when you submit a form with checkboxes, only the ones that are checked will be passed on. [/quote] Hi Ober - thanks for that I just want to hide the record and not delete it. I added a boolean field to the database and set records I want to display to 0. and then changed my SQL statement to say SELECT * FROM casinocredit WHERE `dadded` = 'false' ORDER BY ID ASC and it seems to work fine. Thanks. However my next probelm is how to update the record and change the boolean to 1 (in order to hide it after the check box has been clicked and submitted. Any thoughts? cheers
  17. Hello all, I am currently working on a project, and I need some advice on a couple of things. I am working on a system that displays records from a database. I have included a checkbox beside each record that is displayed, and the idea is that when the user selects the check box and hits submit, the record will disappear from the list of records, but must not be deleted from the database. So my main question is what kind of field will I need to add to my database? Some sort of field that has true/false setting? And from this I take it I must perform a check to see if the record is true or false in order to determine whether or not to display it? this is what my code looks like so far - sorry its probably very amateurish [code]<?php // this is just to show which record has been selected. It displays the record Id at the top of the page if(isset($_POST['record'])) {    $record = $_POST['record'];    $n        = count($record);    $i        = 0;    echo "The record you selected are \r\n" .         "<ol>";    while ($i < $n)    {       echo "<li>{$record[$i]}</li> \r\n";       $i++;    }    echo "</ol>"; } //connect to the database    $dbhost = 'here:3306 '; $dbuser = 'coolhan_admin'; $dbpass = 'wordword'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql'); $dbname = 'coolhan_bigslickreg'; mysql_select_db($dbname); $result = mysql_query( "SELECT * FROM casinocredit ORDER BY ID ASC" ) or die("SELECT Error: ".mysql_error()); // print out the results here $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; echo "<form method='post' action="; echo $_SERVER['PHP_SELF']; echo ">"; // creating a loop for the records $i=0; while ($i < $num) { $id=mysql_result($result,$i,"ID"); $from=mysql_result($result,$i,"dfrom"); $email=mysql_result($result,$i,"demail"); $clubrep=mysql_result($result,$i,"dclubrep"); $amount=mysql_result($result,$i,"damount"); // printing out the records echo "<b>$id</b><br>From: $from<br>Email: $email<br>Club rep: $clubrep<br>Amount: $amount<br>"; echo "<input name='record[]' type='checkbox' value='$id'>"; echo "<hr><br>"; $i++; } echo "<input name='send' type='submit' id='send' value='Send!'></form>" ?>[/code] If anyone could offer me any advice I greatly appreciate it:) Thanks John
  18. Hello all, I have some code below that creates an email from a web form : [code]<?php // create the email message $msg .= "Please create this account and credit it with $10 \n\n\n"; $msg .= "ACCOUNT DETAILS \n\n"; if ($nickname != "") {      $msg .= "Nick Name : $nickname\n";      } if ($username != "") {      $msg .= "User Name : $username\n";      } if ($password != "") {      $msg .= "Password : $password\n\n";      } $msg .= "Personal DETAILS \n\n"; if ($from != "") {      $msg .= "First Name : $from\n";      } if ($middlename != "") {      $msg .= "Middle Name : $middlename\n";      } if ($lastname != "") {      $msg .= "Last Name : $lastname\n";      } if ($dateofbirth != "") {      $msg .= "Date of Birth : $dateofbirth\n";      } $msg .= "Address : $address\n"; if ($town != "") {      $msg .= "Town : $town\n";      } if ($postcode != "") {      $msg .= "Postcode : $postcode\n";      } if ($county != "") {      $msg .= "County : $county\n";      } if ($country != "") {      $msg .= "Country : $country\n";      } if ($telephone != "") {      $msg .= "Telephone : $telephone\n";      } if ($email != "") {      $msg .= "Email : $email\n";      } if ($bigslickprivate != "") {      $msg .= "Join the Big Slick Private Members club? : $bigslickprivate\n";      } if ($bigslickplayers != "") {      $msg .= "Join the Big Slick Players Club? : $bigslickplayers\n";      } if ($bigslickpreffered != "") {      $msg .= "Obtain membership to Big Slick's preferred members club? : $bigslickpreffered\n\n";      } $msg .= "Sent : $today\n"; $mailheaders = "Poker account registration ( $username ) \n"; $mailheaders = "From: $email"; mail($to, $subject, $msg, $mailheaders);[/code] I am trying to have the users email address (the person who has just filled out the form) appear in the "from" field, but the webserver seems to fill in its own address. here is how I have the from address set up : [code]$mailheaders = "From: $email"; [/code] the $email variable is populated from a form field. Any Ideas how to do this? Thanks: [b]EDITED BY WILDTEEN: PLEASE USE THE CODE TAGS RATHER THAN THE PHP TAGS AS THE PHP TAGS NO LONGER EXIST. THANK YOU[/b]
  19. [!--quoteo(post=368436:date=Apr 25 2006, 08:51 AM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 25 2006, 08:51 AM) [snapback]368436[/snapback][/div][div class=\'quotemain\'][!--quotec--] $headers .= "From: \"".$senders_email."\" <".$senders_email.">\n"; mail($recipient, $subject, $message, $headers); hope this helps. [/quote] Thanks!
  20. Hello all, I have a php script that processes a web form, sends and email and insert the information into a MySQL database. It all works fine, but I am trying to make some modifications to it and I'm not sure how to do it. I keep making changes and breaking it every time! The first thing I am trying to do is change how the email is sent. When the email is sent to the recipient, the sender email address seems to be generated by the web server that the script is sitting on. I was hoping to change it to the email that the user entered with the form ($email). any ideas how this is done? Heres what me code looks like: [code]<?php // read in variables from form $to = $to; $from = $from; $email = $email; $subject = "Registration"; $address = $address; $middlename = $middlename; $lastname = $lastname; $dateofbirth = $dateofbirth; $town = $town; $county = $county; $country = $country; $postcode = $postcode; $telephone = $telephone; $nickname = $nickname; $password = $password; $bigslickprivate = $bigslickprivate; $bigslickplayers = $bigslickplayers; $bigslickpreffered = $bigslickpreffered; $today = date ("l, F jS Y"); // database stuff $dbhost = 'host in here '; $dbuser = 'coolhan_admin'; $dbpass = 'wordword'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql'); $dbname = 'coolhan_bigslickreg'; mysql_select_db($dbname); $sql = "INSERT INTO players (dfirstname,dmiddlename,dlastname,demail, ddateofbirth, daddress, dtown, dcounty, dcountry, dpostcode, dtelephone, dnickname, dpassword, dprivateclub, dplayerclub, dpreferredclub) VALUES ('$from','$middlename','$lastname','$email','$dateofbirth','$town','$county','$country', '$postcode','$telephone','$nickname','$password','$bigslickprivate','$bigslickprivate','$bigslickplayers','$bigslickpreffered')"; $result = mysql_query($sql); // check that required forms are complete if (($to == "") || ($from == "") || ($email == "") || ($subject == "") || ($address == "") || ($middlename == "") || ($lastname == "") || ($dateofbirth == "") || ($town == "") || ($county == "") || ($country == "") || ($postcode == "") || ($telephone == "") || ($nickname == "") || ($password == "") || ($bigslickprivate == "") || ($bigslickplayers == "") || ($bigslickpreffered == "")) {         readfile("blankfields.html");        exit;        } else {        } // check email format if (($email != "")) {         $locationofat = strpos($email, '@');         $locationofdot = strrpos($email, '.');         if (($locationofat == "0") || ($locationofdot < $locationofat) || $locationofdot == "0") {                 readfile("bademail.html");                 exit;                 } else {                 } } // create the email message $msg .= "PLEASE FORWARD THIS EMAIL TO bigslick@website.com \n\n\n"; if ($from != "") {      $msg .= "First Name : $from\n";      } if ($middlename != "") {      $msg .= "Middle Name : $middlename\n";      } if ($lastname != "") {      $msg .= "Last Name : $lastname\n";      } if ($email != "") {      $msg .= "Email : $email\n";      } if ($dateofbirth != "") {      $msg .= "Date of Birth : $dateofbirth\n";      } $msg .= "Address : $address\n"; if ($town != "") {      $msg .= "Town : $town\n";      } if ($county != "") {      $msg .= "County : $county\n";      } if ($country != "") {      $msg .= "Country : $country\n";      } if ($postcode != "") {      $msg .= "Postcode : $postcode\n";      } if ($telephone != "") {      $msg .= "Telephone : $telephone\n";      } if ($nickname != "") {      $msg .= "Nick Name : $nickname\n";      } if ($password != "") {      $msg .= "Password : $password\n";      } if ($bigslickprivate != "") {      $msg .= "Join the Big Slick Private Members club? : $bigslickprivate\n";      } if ($bigslickplayers != "") {      $msg .= "Join the Big Slick Players Club? : $bigslickplayers\n";      } if ($bigslickpreffered != "") {      $msg .= "Obtain membership to Big Slick's preferred members club? : $bigslickpreffered\n\n";      } $msg .= "Sent : $today\n"; // send the email $mailheaders = "BigSlick Site registration ( $from )<> \n"; $mailheaders .= "Reply-To: $email\n\n"; mail($to, $subject, $msg, $mailheaders); // pull in the thank you file readfile("thankyou.html"); exit; ?>[/code] Thanks guys, John
×
×
  • 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.