Jump to content

dawsba

Members
  • Posts

    180
  • Joined

  • Last visited

    Never

Everything posted by dawsba

  1. if you hold the scores in an array, cheat - use serialize and unserialize $dbdata = serialize($scorearray); $dbinject = mysql_query("INSERT INTO `tbl_dataheldhere` (`id`,`userid`,`date`,`data`)VALUES('','$userid',NOW(),'$dbdata')");
  2. its real easy, its how your passing the format rules to str_to_date your using hyphons so change the str_to_date to STR_TO_DATE('$birthdate','%m-%d-%Y')
  3. it doesnt really matter about the brackets, i dont, but i know it is done. the error is coming because you called the column header but probably defined no data ie insert into `table` (`id`,`data`)value('',) where it should be like insert into `table` (`id`,`data`)value('','') whats the value of birthdate if you echo it outside the sql?
  4. try this "INSERT INTO costumers (firstname,lastname,birthdate,telephone,product_name,price,details,category,subcategory,city,state,zipcode, country) VALUES('$fname','$lname', STR_TO_DATE('$birthdate','%d,%m,%Y'), '$telephone','$itemname','$price','$details','$category','$subcategory','$city','$state','$zipcode','$country')"; to note this presumes your using $birthdate as "20,03,1979" if your using "20/03/1979" change the above to '%d/%m/%Y' etc etc
  5. slightly tidier, but not tested <?php include("../../../cart/includes/openDbConn.php"); $sql = "SELECT Name FROM FabricType"; $dogettype = 'SELECT Type FROM FabricsTypes WHERE SKU = "'.$sku.'";'; $result = mysql_db_query($dbname,$sql,$link) or die("Invalid Query<br>". mysql_error()); while($results = mysql_fetch_array($result)) { if( $i % 3 == 0 ) { echo '</tr><tr>'; } $result2 = mysql_db_query($dbname,$dogettype,$link) or die("Invalid Query<br>". mysql_error()); while($results2 = mysql_fetch_array($result2)) { if($results2['Type'] == $results['Name']) { $ischecked = 'checked="checked"'; $value = 1; } else { $ischecked = ''; $value = 0; } $i++; $tn = trim(ucfirst($results["Name"])); echo '<td> <label> <input type="checkbox" name="typeGroup1[]" $ischecked value="$value"> '.$tn.' </label> </td>'; } } ?>
  6. on a quick glance, you are missing a bracket in your JS <script type="text/javascript"> function checkme() { if(!document.forms[0].date_disclo_att.value.match(/\d{4}-\d{1,2}-\d{1,2}/)) { alert("ATTENTION: Please enter your start date in the format yyyy-mm-dd."); document.forms[0].date_disclo_att.focus(); return(false); } else { return true; } } </script>
  7. Try Adding: $imageData = file_get_contents($_FILES['userfile']['tmp_name']); $imageData = mysql_real_escape_string($imageData ); <?php //Set variables from form $title = $_POST["title_textfield"]; $description = $_POST["description_textbox"]; $price = $_POST["price_textfield"]; $time = date("ymdHis"); $me = $myuserID /Create Table $con = mysql_connect("mydatabase.mysql.com","databaseAdmin","Adminpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } //check if table exists // Create table $time = date("ymdHis"); $tablename = "1_$me$time"; mysql_select_db("db_01", $con); $sql = "CREATE TABLE $tablename ( ID int NOT NULL AUTO_INCREMENT, imageData LONGBLOB NOT NULL , PRIMARY KEY(comicID), Owner varchar(15), Status varchar(15), AgeRestriction varchar(25), Title varchar(25), Description varchar(100), Price varchar(15) )"; // Execute query mysql_query($sql,$con); //input info into table mysql_query("INSERT INTO $tablename (Owner, Status, Title, Description, Price) VALUES ('$myid', 'Pending', '$title', '$description', '$price')"); //Image control!!!! $maxFileSize = "2000000"; // 2 MB file size //Initializing the image types. $image_array = array("image/jpeg","image/jpg","image/gif","image/bmp","image/pjpeg","image/png"); // valid image type //store the file type of the uploading file. $fileType = $_FILES['userfile']['type']; $nname= $_FILES['userfile']['name']; echo "$nname"; //Initializing the msg variable. Although , not necessary. $msg = ""; // if Submit button is clicked if(@$_POST['Submit']) { // check for the image type , before uploading if (in_array($fileType, $image_array)) { // check whether the file is uploaded if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { // check whether the file size is below 2 mb if($_FILES['userfile']['size'] < $maxFileSize) { // reading the image data $imageData = file_get_contents($_FILES['userfile']['tmp_name']); $imageData = mysql_real_escape_string($imageData ); // inserting into the database $sql = "INSERT INTO $tablename (imageData) VALUES ('$imageData')"; mysql_query($sql) or die(mysql_error()); $msg = " Data successfully uploaded"; } else { $msg = " Error : File size exceeds the maximum limit "; } } } else { $msg = "Error: Not a valid image "; } } mysql_close($con); ?>
  8. can you post the contact_form.php; but as a guess id say add a pre and post array keys and define them in there as step 1
  9. you have a database already!?! why not store it in there!?
  10. I had a quick scan try these on line 130 add enctype='multipart/form-data' into the form line why on lines 22 -> 35 have you got `` if($_POST[‘submit’]) { if($_SESSION[‘SESS_LOGGEDIN’]) { if($_POST[‘addselecBox’] == 2) { if(empty($_POST[‘forenameBox’]) || empty($_POST[‘surnameBox’]) || empty($_POST[‘add1Box’]) || empty($_POST[‘add2Box’]) || empty($_POST[‘add3Box’]) || empty($_POST[‘postcodeBox’]) || empty($_POST[‘phoneBox’]) || empty($_POST[‘emailBox’])) you could try if($_POST['submit']) { if($_SESSION['SESS_LOGGEDIN']) { if($_POST['addselecBox'] == 2) { if(empty($_POST['forenameBox']) || empty($_POST['surnameBox']) || empty($_POST['add1Box']) || empty($_POST['add2Box']) || empty($_POST['add3Box']) || empty($_POST['postcodeBox']) || empty($_POST['phoneBox']) || empty($_POST['emailBox'])) Well i got bored heres somthing that should b ok, i didnt test though <?php session_start(); require("db.php"); $check = array('forenameBox','surnameBox','add1Box','add2Box','add3Box','postcodeBox','phoneBox','emailBox'); function isempty($array) { global $check; foreach($array as $key => $val) { if(empty($val)&&in_array($key,$check)){return true;} } return false; } function tidy($var,$b4=NULL,$after=NULL) { if(is_array($var)) { foreach($array as $key => $val) { return $b4.strip_tags(addslashes($val)).$after; } } else { return $b4.strip_tags(addslashes($var)).$after; } } $statussql = "SELECT status FROM orders WHERE id = " . $_SESSION['SESS_ORDERNUM']; $statusres = mysql_query($statussql); $statusrow = mysql_fetch_assoc($statusres); $status = $statusrow['status']; if($status == 1) { header('Location: ' . $config_basedir . 'checkout-pay.php'); } if($status >= 2) { header('Location: ' . $config_basedir); } if($status >= 2) { header('Location: ' . $config_basedir); } if($_POST[‘submit’]) { if($_SESSION[‘SESS_LOGGEDIN’]) { if($_POST[‘addselecBox’] == 2) { if(isempty($_POST)) { header('Location: ' . $basedir . 'checkout-address.php?error=1'); exit; } $addsql = "INSERT INTO delivery_addresses(forename, surname, add1, add2, add3, postcode, phone, email) VALUES('" . tidy($_POST['forenameBox']) . "', '" . tidy($_POST['surnameBox']) . "', '" . tidy($_POST['add1Box']) . "', '" . tidy($_POST['add2Box']) . "', '" . tidy($_POST['add3Box']) . "', '" . tidy($_POST['postcodeBox']) . "', '" . tidy($_POST['phoneBox']) . "', '" . tidy($_POST['emailBox']) . "')"; mysql_query($addsql); $setaddsql = "UPDATE orders SET delivery_add_id = " . mysql_insert_id() . ", status = 1 WHERE id = " . $_SESSION['SESS_ORDERNUM']; mysql_query($setaddsql); header("Location: " . $config_basedir . "checkout-pay.php"); } else { $custsql = "UPDATE orders SET delivery_add_id = 0, status = 1 WHERE id = " . $_SESSION['SESS_ORDERNUM']; mysql_query($custsql); header("Location: " . $config_basedir . "checkout-pay.php"); } } else { if(isempty($_POST)) { header("Location: " . "checkout-address.php?error=1"); exit; } $addsql = "INSERT INTO delivery_addresses(forename, surname, add1, add2, add3, postcode, phone, email) VALUES('" . $_POST['forenameBox'] . "', '" . $_POST['surnameBox'] . "', '" . $_POST['add1Box'] . "', '" . $_POST['add2Box'] . "', '" . $_POST['add3Box'] . "', '" . $_POST['postcodeBox'] . "', '" . $_POST['phoneBox'] . "', '" . $_POST['emailBox'] . "')"; mysql_query($addsql); $setaddsql = "UPDATE orders SET delivery_add_id = " . mysql_insert_id() . ", status = 1 WHERE session = '" . session_id() . "'"; mysql_query($setaddsql); header("Location: " . $config_basedir . "checkout-pay.php"); } } else { require("header.php"); echo "<h1>Add a delivery address</h1>"; if(isset($_GET['error']) == TRUE) { echo "<strong>Please fill in the missing information from the form</strong>"; } echo "<form action='" . $SCRIPT_NAME . "' method='POST'>"; if($_SESSION['SESS_LOGGEDIN']) { ?><form enctype='multipart/form-data' <input type="radio" name="addselecBox" value="1" checked>Use the address from my account</input><br> <input type="radio" name="addselecBox" value="2">Use the address below:</input> <?php } ?> <table> <tr> <td>Forename</td> <td><input type="text" name="forenameBox"></td> </tr> <tr> <td>Surname</td> <td><input type="text" name="surnameBox"></td> </tr> <tr> <td>House Number, Street</td> <td><input type="text" name="add1Box"></td> </tr> <tr> <td>Town/City</td> <td><input type="text" name="add2Box"></td> </tr> <tr> <td>County</td> <td><input type="text" name="add3Box"></td> </tr> <tr> <td>Postcode</td> <td><input type="text" name="postcodeBox"></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="phoneBox"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="emailBox"></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Add Address (press only once)"></td> </tr> </table> </form> <?php } require("footer.php"); ?>
  11. <?php unset($error,$name,$email,$comment); if(isset($_POST['submit'])) //<- check if submit button has been clicked. { include('database_connection.php'); //<- include our connection details for database interaction. $name = $_POST['name']; //<- set name input to a variable. $email = $_POST['email']; //<- set email input to a variable. $comment = $_POST['comment']; //<- set textbox to variable. if(empty($name)){$error .= '--Must have a name. <br />';} $estr = '~^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$~'; if(empty($email)||preg_match($estr,$email)){$error .= '--Must have a valid email address. <br />';} if(empty($comment)){$error .= '--Must leave a comment. <br />';} if(!isset($error)) //<- if there are no error messages. { $sql = sprintf("INSERT INTO `feedback` (`name`,`email`,`comment`)VALUES('%s','%s','%s')", mysql_real_escape_string($name), mysql_real_escape_string($email), mysql_real_escape_string($comment)); if(mysql_query($sql)){$error .= 'Thank you for your comment!';} else{$error .= 'There was an error in our Database, please Try again!';} } else{echo $error;} } ?> <form action="" method="post" enctype="multipart/form-data"> <label for="name">Name: <input type="text" name="name" value="<?php echo $name; ?>" /></label><br /> <label for="email">Email: <input type="text" name="email" value="<?php echo $email; ?>" /></label><br /> <label for="comment">Comment: </label><br /> <textarea name="comment" cols="40" rows="10"><?php echo $comment; ?></textarea> <input type="submit" name="submit" value=" Submit " /> </form> how does this get on?
  12. and heres my 2pence for fun <?PHP $Var = array(1=>'name',2=>'roundx'); $alpha = array("a","b","c","d","e","f","g","h"); $q = array(1=>"SELECT * FROM one WHERE username = '".$Var[1]."'",2=>"SELECT * FROM acs WHERE round1 = '".$Var[2]."'"); $resultU = mysql_query($q[1]); $score = mysql_fetch_assoc($resultU); $resultx = mysql_query($q[2]); $scorex = mysql_fetch_assoc($resultx); for($i=1;$i<=8;$i++) { $UAX = "usera".$i; $$UAX = $score['round'.$i]; $UAXX = "ArrayU".$i; $$UAXX = array($$UAX); $UAX = "win".$i;$j=$i-1; $$UAX = $scorex['inx'.$alpha[$j]]; $UAXX = "Arrayk".$i; $$UAXX = array($$UAX); $UAX = "count".$i; $UAXX = "ArrayU".$i; $UAXXX = "Arrayk".$i; $$UAX = count(array_intersect($$UAXX, $UAXXX) ); } echo($count1+$count2+$count3+$count4+$count5+$count6+$count7+$count8); ?>
  13. picked this up from http://bytes.com/topic/php/answers/3651-email-trigger-php-function Do this: (i know guys, there are other ways to do it with procmailrc, but most people mess that file up) in /etc/mail/virtusertable: someemail@somedomain.com aliasScriptName then in /etc/alaises aliasScriptName "| /etc/smrsh/scriptname" then in /etc/smrsh/scriptname #!/usr/bin/php -q <?php // read from stdin $fd = fopen("php://stdin", "r"); while (!feof($fd)) { $inData = fgets($fd, 1024); $inData = trim($inData); .. proccess $inData here ... } fclose($fd); ?>
  14. if($numrows != 1) should be if($numrows <= 0)
  15. /* DATABASE CONNECTION INFO */ define("TABLE", "tbl_order"); function q($query,$assoc=1) { $r = @mysql_query($query); if( mysql_errno() ) { return FALSE; } if( strtolower(substr($query,0,6)) != 'select' ) return array(mysql_affected_rows(),mysql_insert_id()); $count = @mysql_num_rows($r); if( !$count ) return 0; if( $count == 1 ) { if( $assoc ) $f = mysql_fetch_assoc($r); else $f = mysql_fetch_row($r); mysql_free_result($r); if( count($f) == 1 ) { list($key) = array_keys($f); return $f[$key]; } else { $all = array(); $all[] = $f; return $all; } } else { $all = array(); for( $i = 0; $i < $count; $i++ ) { if( $assoc ) $f = mysql_fetch_assoc($r); else $f = mysql_fetch_row($r); $all[] = $f; } @mysql_free_result($r); return $all; } } function changeStatus($id,$type) { $sqlw = "WHERE `id` = '".$id."'"; $sqlx = "FROM `".TABLE."` ".$sqlw; $sqlu = 'UPDATE `".TABLE."` SET `OrderID`=`OrderID`'; if(q("SELECT COUNT(*) ".$sqlx)==1) { $Oid = q("SELECT `OrderID` ".$sqlx." LIMIT 1"); $catid = q("SELECT `CatalogID` ".$sqlx." LIMIT 1"); switch($type) { case 1: if($Oid>1) { q("-1 ".$sqlw." LIMIT 1"); q($sqlu."+1 WHERE `CatalogID` = '".$catid."' AND `id` != '".$id."' AND `OrderID` >= '".$id."'"); } break; case 2: q($sqlu."+1 ".$sqlw." LIMIT 1"); q($sqlu."-1 WHERE `CatalogID` = '".$catid."' AND `id` != '".$id."' AND `OrderID` >= '".$id."' AND `OrderID` != 1"); break; case 3: q("DELETE ".$sqlx." LIMIT 1"); q($sqlu."-1 WHERE `CatalogID` = '".$catid."' AND `id` != '".$id."' AND `OrderID` >= '".$id."' AND `OrderID` != 1"); break; } } } /* status types 1 = up 2 = down 4 delete function changeStatus syntax changeStatus($id,$type) //$id is the row id, $type is status type */ changeStatus(2,1); I havnt had chance to test but should do the job for you have fun
  16. can u give alittle more info? have you got any code so far
  17. what kind of database ? mysql?? have you already a structure if so can u display here?
  18. function replace_multiple_spaces($string) { // tabs, new lines and carriages are also replaced $string = ereg_replace("[ \t\n\r]+", " ", $string); return $string; } $string = "This is a dummy text. "; $new_string = replace_multiple_spaces($string); // Outputs: This is a dummy text echo $new_string;
  19. 2 easy choices, 1 being define : define("COMPANYNAME", "ABC Ltd"); defines are ok, but if you need to change them on the fly not so good. or my personal favorite session $_SESSION[COMPANYNAME] = "ABC Ltd";
  20. your not loading contact.php, or it doesnt appear to be. if your not doing already i would suggest : <a href="contact.php" onclick="showhide(document.all['storecat1_div']); return false;" class="storecat" style="margin-top:1px;border-top: 1px solid #DFDFDF;"><b>Contact Us</b></a> <div id=storecat1_div style='display: none;'> <?PHP include 'contact.php'; //path to contact page ?> </div>
  21. you should read up on pagination: but for a dirty way function stripName() //strip the page number from script name { $page = strtolower($_SERVER[php_SELF]); $pref = "page"; // prefix of file name to strip $postf = ".php"; // postfix of file to strip return substr($page,strlen($pref)-1,strlen($page)-(strlen($postf)+strlen($pref))); } function filec($page) //check file exists { if(file_exists($page)){return true;}else{return false;}return false; } $thispage = stripName(); // grab page number $prevpage = $thispage-1; // previous page $nextpage = $thispage+1; // nextpage if(!filec($prevpage)){$prevpage=$thispage;$noprev=1;} // check previous page exists if(!filec($nextpage)){$nextpage=$thispage;$nonext=1;} // check next page exists if(!isset($noprev)){$links = "<a href=\"".$prevpage."\">[ Previous Page ]</a>";} // build the link if previous exists if(!isset($nonext)){$links .= "<a href=\"".$nextpage."\">[ Next Page ]</a>";} // build the link if next exists echo $links; // display links to screen hope this helps
  22. Hi Prcollin, i've actually built this in 2 ways before, it all depends on the amount of information your intending to retrive, if your bringing lots back id run it with curl, if its only a few lines your probably best with javascript ajax call.
  23. Try this:(presuming your assigning keys and PID is set as an index or UNIQUE mysql_query("INSERT INTO `limetree_uni`.`Products` (`PID`,`Product_Cat`,`Product_Title`,`Product_Description`,`Product_Shipping`,`Product_Stock`,`Product_Price) VALUES ('$EID','".$Product_CAT_SET."','".$New_Title."','".$New_Description."','".$New_Shipping."','".$New_Stock."','".$New_Price."') ON DUPLICATE KEY UPDATE `Product_Cat` = '".$Product_CAT_SET."',`Product_Title` = '".$New_Title."',`Product_Description` = '".$New_Description."', `Product_Shipping` = '".$New_Shipping."', `Product_Stock` = '".$New_Stock."', `Product_Price` = '".$New_Price."'");
  24. gzip compression is an apache mod, you can enable this through htaccess or if u have cpanel.
×
×
  • 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.