Jump to content

anilvaghela

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

anilvaghela's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. but how would i put the file into the following directory: /logs/data/stats/content/tmpupload i dont know where to begin with the function you assume will work.... thanks
  2. Hello Guys n Girls... I have a script below... <?php $host = 'servername'; $user = 'username'; $pass = 'password'; $db = 'stats_db'; $table = 'ref_export'; $file = 'export'; $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $values1 = mysql_query("show columns from ref_col"); //$i = 0; //$txt_output = ""; if (mysql_num_rows($values1) > 0) { while ($row = mysql_fetch_assoc($values1)) { $txt_output .= $row['Field'].","; $i++; } $txt_output = substr( $txt_output , 0, -1 ); $txt_output .= $row[$i-1]; //$txt_output .= "\r\n"; } //$values = mysql_query("select order_id as 'order', name_id as 'id', name_ch as name, parent_id as 'parent-id',level, aggregate, pseudo, ps_id as 'ps-id', replevel, class, audit_list.audit from ref_export inner join audit_list on (ref_export.audit=audit_list.id) order by order_id asc"); $values = mysql_query("select * from ref_export order by order_id asc"); while ($rowr = mysql_fetch_row($values)) { $txt_output .= "\r\n"; for ($j=0;$j<$i-1;$j++) { $txt_output .= $rowr[$j].","; } $txt_output .= $rowr[$i-1]; //$txt_output .= "\r\n"; } //$filename = $file."_".date("Y-m-d_H-i",time()); $filename = "channels"; header("Content-type: application/vnd.ms-notepad"); header("Content-disposition: txt" . date("Y-m-d") . ".txt"); header( "Content-disposition: filename=".$filename.".txt"); print $txt_output; exit; ?> This will export the results into a text file which is right.... but I dont want it to export into a text file i want it to save the text file on the server instead.... how do i do this??? please help... anil vaghela
  3. Sorted the problem out.... follow the steps.... In your form add <form id="form3" name="form3" method="post" enctype="multipart/form-data" action="<?php $_SERVER["php_SELF"];?>"> and then i used <?php if ($_POST['checked1']) { foreach($_POST["checked1"] as $key => $id) { $query_update = ("UPDATE ref_db set checked_id = checked_id + 1, tchecked = now() where name_id = '".(int)$id."'"); mysql_query($query_update); } } else { } to call up when submitting..... it worked!!
  4. ok thats something i will look into .... but here is something that i have redeveloped... but it only submits one line and not more than one..... I believe there is something missing in the last piece of code as the information gets sent through but only updates one and not two more .... Table Information: mysql_select_db($database_mysql, $mysql); $query_not_checked = "SELECT DISTINCT ref_db.name_id, ref_db.name_ch, ref_db.tdate, members.firstname, tbl_requestors.req_name, checked_id.checked, datediff(NOW(), ref_db.tdate) AS Date_Difference FROM members INNER JOIN ref_db ON (members.member_id = ref_db.user_id) INNER JOIN tbl_requestors ON (ref_db.assign_id = tbl_requestors.index_id) INNER JOIN checked_id ON (ref_db.checked_id = checked_id.index_id) WHERE checked_id.index_id LIKE 1 "; $not_checked = mysql_query($query_not_checked, $mysql) or die(mysql_error()); $row_not_checked = mysql_fetch_assoc($not_checked); $totalRows_not_checked = mysql_num_rows($not_checked); <form id="form1" name="form1" method="post" action="<?php $_SERVER["php_SELF"];?>"> <div id="CollapsiblePanel1" class="CollapsiblePanel"> <div class="CollapsiblePanelTab" tabindex="0">Channels Not Checked - (<?php echo $totalRows_not_checked;?>)</div> <div class="CollapsiblePanelContent"> <table width="891" border="1" cellpadding="1" cellspacing="1" class="css_refdb"> <tr> <td width="175"><div align="center"><strong>Name Channel</strong></div></td> <td width="125"><div align="center"><strong>Date Checked</strong></div></td> <td width="138"><div align="center"><strong>User Name</strong></div></td> <td width="143"><div align="center"><strong>Requestor</strong></div></td> <td width="179" class="css_refdb"><div align="center"><strong>Date Difference</strong></div></td> <td width="179"><div align="center"><strong>Checked</strong></div></td> </tr> <?php do { ?> <tr> <td><div align="center"><?php echo $row_not_checked['name_ch']; ?></div></td> <td><div align="center"><?php echo $row_not_checked['tdate']; ?></div></td> <td><div align="center"><?php echo $row_not_checked['firstname']; ?></div></td> <td><div align="center"><?php echo $row_not_checked['req_name']; ?></div></td> <td><div align="center"><?php echo $row_not_checked['Date_Difference']; ?></div></td> <td><div align="center"><input type="checkbox" name="checked[]" value="<?php echo $row_not_checked['name_id'];?>" /></div></td> </tr> <?php } while ($row_not_checked = mysql_fetch_assoc($not_checked)); ?> </table> <br /> <input type="submit" value = "submit" name="submit" id="button" /> <br /> </div> </div> </form> <?php $i=0; $name_id = $_POST['checked']; if (is_array($name_id)){ for ($i=0;$i<count($name_id);$i++) $query_update = "UPDATE ref_db set checked_id = checked_id + 1, tchecked = now() where name_id = '$name_id[$i]'"; mysql_query($query_update); echo $query_update; { } } ?>
  5. hello... I have a php dynamic table where the results show any outstanding channels that need to be checked off. so on the php side i have created the following.... mysql_select_db($database_mysql, $mysql); $query_not_checked = "SELECT DISTINCT ref_db.name_id, ref_db.name_ch, ref_db.tdate, members.firstname, tbl_requestors.req_name, checked_id.checked, datediff(NOW(), ref_db.tdate) AS Date_Difference FROM members INNER JOIN ref_db ON (members.member_id = ref_db.user_id) INNER JOIN tbl_requestors ON (ref_db.assign_id = tbl_requestors.index_id) INNER JOIN checked_id ON (ref_db.checked_id = checked_id.index_id) WHERE checked_id.index_id LIKE 1 "; $not_checked = mysql_query($query_not_checked, $mysql) or die(mysql_error()); $row_not_checked = mysql_fetch_assoc($not_checked); $totalRows_not_checked = mysql_num_rows($not_checked); <form id="form10" name="form10" method="post" action=""> <div id="CollapsiblePanel1" class="CollapsiblePanel"> <div class="CollapsiblePanelTab" tabindex="0">Channels Not Checked - (<?php echo $totalRows_not_checked;?>)</div> <div class="CollapsiblePanelContent"> <table width="891" border="1" cellpadding="1" cellspacing="1" class="css_refdb"> <tr> <td width="175"><div align="center"><strong>Name Channel</strong></div></td> <td width="200"><div align="center"><strong>Date Checked</strong></div></td> <td width="138"><div align="center"><strong>User Name</strong></div></td> <td width="143"><div align="center"><strong>Requestor</strong></div></td> <td width="179"><div align="center"><strong>Date Difference</strong></div></td> <td width="179"><div align="center"><strong>Checked</strong></div></td> </tr> <?php do { ?> <tr> <td><div align="left"><?php echo $row_not_checked['name_ch']; ?></div></td> <td><div align="center"><?php echo $row_not_checked['tdate']; ?></div></td> <td><div align="left"><?php echo $row_not_checked['firstname']; ?></div></td> <td><div align="left"><?php echo $row_not_checked['req_name']; ?></div></td> <td><div align="center"><?php echo $row_not_checked['Date_Difference']; ?></div></td> <td><div align="center"><input type="checkbox" id="ONOFF" name="ONOFF[]" value="<?php echo $row_not_checked['name_id']; ?>"></div></td> </tr> <?php } while ($row_not_checked = mysql_fetch_assoc($not_checked)); ?> </table> <br> <input type="submit" value="Submit" name="submit" id="button" /> <br> </div> </div> </form> Now how do I submit the checked boxes to update the mysql table using the following mysql query.... but remember users can check more than one.... update ref_db set checked_id = checked_id +1, tchecked = now() where name_id = CHECKEDBOX
  6. This is what i did..... <table border="1" > <tr> <td><div align="center" class="style3">Name Ch</div></td> <td><div align="center" class="style3">Level</div></td> </tr> <?php do { if ($row_channels['level']=="-1") { $SPACE="";} if ($row_channels['level']=="0") { $SPACE="--";} if ($row_channels['level']=="1") { $SPACE="----";} if ($row_channels['level']=="2") { $SPACE="------";} if ($row_channels['level']=="3") { $SPACE="--------";} if ($row_channels['level']=="4") { $SPACE="----------";} if ($row_channels['level']=="5") { $SPACE="------------";} //else { $SPACE="";} //$agg = $row_channels['agg']; //$pseudo = $row_channels['pseudo']; //$site = $row_channels['site']; if($row_channels['agg']=="1") { $color = "blue"; } if($row_channels['pseudo'] == "1"){ $color = "green"; } elseif($row_channels['agg'] == "0" AND $row_channels['pseudo'] == "0"){ $color = "red";} else {$color = "black";} ?> <tr> <td><span class="style3" style="color:<?=$color?>"><?php echo $SPACE.''.$row_channels['name_ch']; ?></span></td> <td><span class="style3" style="color:<?=$color?>"><?php echo $row_channels['level'];?></span></td> </tr> <?php } while ($row_channels = mysql_fetch_assoc($channels)); ?> </table>
  7. hello all! ok i am having a problem in inserting a tmp table data into the main table where it increments the order_id from where ever its been pointed to... to go more further here below i explain of the process..... 1 - Main Table has same columns as Temp Table In the main table there is index_id which is auto_increment and order_id which is not but has to be in order from 1 - 2000 for example..... 2 - from the temp table i could have 1 record or 50 records either way the results in the temp table are in order and need to be in that set order through out the process.... 3 - I am able to in php start of with selecting the order_id where the new data will need to sit for example the data may need to sit under order_id - 60 so there fore there will be rows after 60 and this is where the new rows from temp table will sit...... but what problem i am having is when i insert the data under 60 which i use the a @myorder +1 all the data from the temp table inserts there but it does increment by 1 on all the records it shows 61 on all the records. so this is where i need to know how to actually make all the rows increment and if there is only 25 records then after order_id 85 the other records also get updated! i hope you guys n girls understand what i am trying to do here.... here is some code of process.... step 1 : this sets the order_id where the new data will sit.... $sql = sprintf("SELECT @myorder1 := order_id FROM ref_db WHERE name_id = '%s'",mysql_real_escape_string($name_id_add)); mysql_query($sql,$conn) or die(mysql_error($conn)); $sql = sprintf("UPDATE ref_db set order_id = order_id + 1 Where order_id > @myorder1"); mysql_query($sql,$conn) or die(mysql_error($conn)); $sql = sprintf("UPDATE ref_db set order_id = order_id where order_id > @myorder1"); mysql_query($sql,$conn) or die(mysql_error($conn)); step 2: this here inserts the data from the temp table into the main table mysql_select_db($database_mysql, $mysql); $query_tmptbl = "SELECT * FROM tmpmove "; $tmptbl = mysql_query($query_tmptbl, $mysql) or die(mysql_error()); $row_tmptbl = mysql_fetch_assoc($tmptbl); $all_tmptbl = mysql_query($query_tmptbl); $totalRows_tmptbl = mysql_num_rows($all_tmptbl); do { $sql = sprintf("INSERT INTO ref_db(order_id, name_id, name_ch, parent_id, level, agg, pseudo, ps_id, replevel, class, audit, tdate, user_id, checked_id, assign_id) VALUES (@myorder1+1, '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', NOW(),'%s', '%s', '%s')", mysql_real_escape_string($row_tmptbl['name_id']), mysql_real_escape_string($row_tmptbl['name_ch']), mysql_real_escape_string($row_tmptbl['parent_id']), mysql_real_escape_string($row_tmptbl['level']), mysql_real_escape_string($row_tmptbl['agg']), mysql_real_escape_string($row_tmptbl['pseudo']), mysql_real_escape_string($row_tmptbl['ps_id']), mysql_real_escape_string($row_tmptbl['replevel']), mysql_real_escape_string($row_tmptbl['class']), mysql_real_escape_string($row_tmptbl['audit']), mysql_real_escape_string($row_tmptbl['user_id']), mysql_real_escape_string($row_tmptbl['checked_id']), mysql_real_escape_string($row_tmptbl['assign_id'])); mysql_query($sql) or die(mysql_error()); } while ($row_tmptbl = mysql_fetch_assoc($tmptbl)); BUT it does not increment +1 on all and only does the same number on all PLEASE HELP!!! THANKS!! Anil Vaghela
  8. Hi Keith..... Thanks....But to draw it out.... http://linux.heavyvibesonline.com:8080/dev/ref_db/functions/add_definitions.php that is the link to the page on there 1 : you first select a name channel, this then loads up an onchange handler which then supplies hidden boxes with information about the name_id, parent_id and level which is used for posting data. 2 : You have a collapsable panel which shows the results of definitions if any for that specific channel.... as you can the list contains some of the information but i want that list to update once you choose a name channel..... i hope thats a bit more clearer....
  9. Hello guys n girls! ok another one but this one is something i have attempted to work on..... I have a form which looks up data from a mysql table. Text field: Name channel ( here you would select the name channel) The text field box also has an onchange handler which looks up the name_id, and parent_id for that channel and places this information into two other boxes. Now I want to know on the same form how or when you select a name channel from the text field it also then populates a list of all the definitions from another table into a dynamic table on the page. So basically you choose a name_ch and it uses the name_id which is unique to that name_ch and looks up all records that have defintions assigned to that name_id from another table.... query for definitions is select definitions from tbl_def where name_id ="" ..... i am have problems here and need to know exactly what to use or do.... please help!! thanks Anil Vaghela
  10. Thanks but how do i build it into a sql script to show the results in php?
  11. Hello there guys n girls.... This one is something of something i need help on... I have a table which has the following columns. namechannel = values = varchar agg = values = 1 or 0 pseudo = values = 1 or 0 now what i want to do in php is to list all the namechannels and say for example: one row = namechannel and also agg = 1 ( i want the namechannel to be blue) one row = namechannel and also pseudo = 1 ( i want the namechannel to be green) one row = namechannel and also pseudo and agg = 0 ( i want the namechannel to be red) I have had a look about but cant find the functionality for this and would really would appreciate some help on this please. Thanks! Anil Vaghela
  12. yes i have attempted this but i still have problems
  13. Hi.... I have created a php mysql login scripts for a web project and i have moved this from dev to live server but realised that mysqli extension will not be allowed and i will have to work with mysql extentsions only. Below I have 2 files. 1 - Mysqli Connection File ( need to know what is needed to be changed in here to mysql) <?php # Script 16.4 - mysqli_connect.php // This file contains the database access information. // This file also establishes a connection to MySQL // and selects the database. // Set the database access information as constants: DEFINE ('DB_USER', 'user'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'host'); DEFINE ('DB_NAME', 'db'); // Make the connection: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (!$dbc) { trigger_error ('Could not connect to MySQL: ' . mysqli_connect_error() ); } ?> 2 - Registration Page, on this page i just need to work out how to change some of the functions which rely on mysqli to be converted to mysql... <?php # Script 16.6 - register.php // This is the registration page for the site. include ('includes/header.html'); require_once ('includes/config.inc.php'); $page_title = 'Register'; if (isset($_POST['submitted'])) { // Handle the form. require_once (MYSQL); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $fn = $ln = $e = $p = FALSE; // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) { $fn = mysqli_real_escape_string ($dbc, $trimmed['first_name']); } else { echo '<p class="error">Please enter your first name!</p>'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimmed['last_name'])) { $ln = mysqli_real_escape_string ($dbc, $trimmed['last_name']); } else { echo '<p class="error">Please enter your last name!</p>'; } // Check for an email address: if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'])) { $e = mysqli_real_escape_string ($dbc, $trimmed['email']); } else { echo '<p class="error">Please enter a valid email address!</p>'; } // Check for a password and match against the confirmed password: if (preg_match ('/^\w{4,20}$/', $trimmed['password1']) ) { if ($trimmed['password1'] == $trimmed['password2']) { $p = mysqli_real_escape_string ($dbc, $trimmed['password1']); } else { echo '<p class="error">Your password did not match the confirmed password!</p>'; } } else { echo '<p class="error">Please enter a valid password!</p>'; } if ($fn && $ln && $e && $p) { // If everything's OK... // Make sure the email address is available: $q = "SELECT user_id FROM users WHERE email='$e'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_num_rows($r) == 0) { // Available. // Create the activation code: $a = md5(uniqid(rand(), true)); // Add the user to the database: $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() )"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. // Send the email: $body = "Thank you for registering at <URL TO BE REDIRECTED TO>. To activate your account, please click on this link:\n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'], 'Registration Confirmation', $body, 'From: '); // Finish the page: echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; include ('includes/footer.html'); // Include the HTML footer. exit(); // Stop the page. } else { // If it did not run OK. echo '<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; } } else { // The email address is not available. echo '<p class="error">That email address has already been registered. If you have forgotten your password, use the link at right to have your password sent to you.</p>'; } } else { // If one of the data tests failed. echo '<p class="error">Please re-enter your passwords and try again.</p>'; } mysqli_close($dbc); } // End of the main Submit conditional. ?> Your support will be appreciated. Thanks Anil Vaghela anil@heavyvibesonline.com www.heavyvibesonline.com
  14. Just one more thing about the above equation that did work for the 'conn:getinstance' query.... how would i bind the following..... $stmt = conn::getInstance()->prepare("INSERT INTO ref_db(order_id, name_id, name_ch, parent_id, level, agg, pseudo, ps_id, replevel, class, audit, tdate, user_id, checked_id, assign_id) VALUES(@myorder1 +1, :name_id, :move_node, :parent_id, :level, :agg, :pseudo, :ps_id, :replevel, :class, :audit, NOW(), :user_id, :checked_id, :assign_id)"); $stmt->bindParam(':name_id', $name_id); $stmt->bindParam(':move_node', $move_node); $stmt->bindParam(':parent_id', $parent_id); $stmt->bindParam(':level', $level); $stmt->bindParam(':agg', $agg); $stmt->bindParam(':pseudo', $pseudo); $stmt->bindParam(':ps_id', $ps_id); $stmt->bindParam(':replevel', $replevel); $stmt->bindParam(':class', $class); $stmt->bindParam(':audit', $audit); $stmt->bindParam(':user_id', $user_id); $stmt->bindParam(':checked_id', $checked_id); $stmt->bindParam(':assign_id', $assign_id); $stmt->execute();
×
×
  • 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.