PHP - @fopen @fwrite @fclose Doesnt Work Need Help, Using Variables ><
Code: [Select]
if(isset($_COOKIE['ID_my_site'])) { $username = mysql_real_escape_string( $_COOKIE['ID_my_site'] ); $pass = mysql_real_escape_string( $_COOKIE['Key_my_site'] ); $check = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$pass'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass == $info['password']) echo "$username"; } } if (isset($_POST['submit'])) { $firstname = ($_POST['firstname']); $lastname = ($_POST['lastname']); $filename = "***/$username.info.php" or exit("Unable to open file!"); $handle = @fopen($filename, 'x+')or die(mysql_error()); $content = "nothing i enter here gets inserted into the file"; @fwrite($handle, $content)or die(mysql_error()); @fclose; } Similar TutorialsHey guys, I have a script that is run once a week to fetch some user info for a large number of accounts. The code I have now writes the info correctly, but I was wondering if there was an easy way to have the accountdata.txt file completely wiped before new updated info is written to it, as opposed to deleting it manually every week. $FileName = "accountdata.txt"; $f=fopen($FileName,"a+"); fwrite($f, $UserKey[$i]." ".$SigKey[$i]."\n"); $f=fclose; I could in theory just open the file and delete everything in it manually, save it and then run this script, but I'm always looking for more ways to make things efficient, and come a time when it's run more than once a week it'd be nice to have all that automated. So in summary, I need it to delete all data (if any) from the accountdata.txt file before it writes anything to it. Thanks. Can't figure out why the page wont save after clicking save. $KOHDE="index.php?s=admin"; $LOMAKE_W = 400; $TEXTAREA_W = 50; $TEXTAREA_H = 20; $LOMAKE = mysql_real_escape_string($_GET["l"]); $LOMAKE2 = mysql_real_escape_string($_POST["lomake"]); after a few more lines... elseif ($LOMAKE2 == "etusivu"){ #Etusivun muokkaus $teksti = stripslashes($_POST["teksti"]); $f = fopen("etusivu.php", "w"); fwrite($f, $teksti); fclose($f); } elseif ($LOMAKE == "etusivu"){ #Etusivun muokkaus echo "<h1>Edit home page</h1>"; $f = file("etusivu.php"); echo "<form action='$KOHDE' method='post'> <textarea name='teksti' cols='$TEXTAREA_W' rows='$TEXTAREA_H'>"; for ($i = 0; $i < count($f); $i++){ $f[$i] = str_replace("\"", "''", $f[$i]); echo $f[$i]; } echo "</textarea> <input type='hidden' value='etusivu' name='lomake'/> <br><input type='submit' value='Save'/> </form><br/>"; html_ohje(); } I can't see where it has gone wrong. Can anyone help? Greetings all, I'm completely stumped...so I'd like to run this issue by you guys (and gals!). I have encountered an odd issue, and I have no idea why this is doing what it's doing. When I execute the following code, all by itself, in an "index.php" file (with no other files around...completely isolated!) I get a result of "testtest" $log_file = 'all.txt'; $handle = fopen($log_file, 'a'); fwrite($handle, 'test'); fclose($handle); Note: I delete the file each time I execute the script (in a browser). I am also the only one running this script. I've tried running on PHP 5.2.x and PHP 5.3.x I have also tried on my machine as well as a separate, remote machine. Is the script running twice? If so, what's causing it? Any help is appreciated as always! Ryan $DOCUMENT_ROOT=$_SERVER['DOCUMENT_ROOT']; $outputstring = $date."\t".$tireqty." tires \t".$oilqty."oil\t".$sparkqty." spark plugs\t\$".$totalamount."\t".$address."\n"; //open file for appending @$fp = fopen('$DOCUMENT_ROOT/../orders/orders.txt', 'ab'); if (!$fp) { echo '<p><strong>Your order can not be processed at this time. Please try again later</strong></p></body></html>'; exit; } //write to file fwrite($fp, $outputstring, strlen($outputstring)); flock($fp, LOCK_UN); fclose($fp); Can someone please explain to me why this Code is giving me the error? i've tried to take out $DOCUMENT_ROOT and specify where exactly i want the file to be /dir/dir/file.txt but it still gives me an error. I am getting a rediculous amount of errors in the log on my host saying the following but for numerous referer addresses. Code: [Select] [Wed Sep 21 12:15:32 2011] [error] [client 85.189.254.101] PHP Warning: fwrite(): supplied argument is not a valid stream resource in /home/sites/myurl.co.uk/public_html/Category.php on line 122, referer: http://www.myurl.co.uk/Category/En/Floats/ it is a simple cache system i use and it appears to work as when you view source at the bottom of the page is the comment about the file being cached and retrieved. My page code: Code: [Select] <?php $cat = $_GET["cat"]; $sub_cat = $_GET["sub"]; $language = $_GET["lang"]; $cachefile = "cache/".$cat."-".$sub_cat."-".$language.".html"; $cachetime = 60 * 60 * 400; // 5 days // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) { include($cachefile); echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." -->"; exit; } ob_start(); // start the output buffer include("./includes/db_con.inc.php"); $page_title = $cat . " - " . $sub_cat; $sql_meta = mysql_query("SELECT * FROM sub_cat WHERE name='$sub_cat'"); $row_meta = mysql_fetch_assoc($sql_meta); $meta_desc = $row_meta['META_DESC']; $meta_key = $row_meta['META_KEY']; include("./includes/head.php"); include("./includes/header.php"); mysql_free_result($sql_meta); ?> <div id="main-page-header"> <?php $desc_sql = mysql_query("SELECT * FROM sub_cat WHERE name='$sub_cat'"); $row_desc = mysql_fetch_assoc($desc_sql); $description = $row_desc['description']; echo "<img src='$img_loc/product-pages/sub-cat-head/".str_replace(" ", "-", $row_desc['name'])."-sub-cat-head.jpg' width='940' height='310' />"; mysql_free_result($desc_sql); ?> </div> <div id="page-content"> <div id="main-page-text"> <h1><?php echo $sub_cat; ?></h1> <h2 class="crumbs"><a href="<?php echo "$url/Products/$lang/"; ?>">Products</a> > <a href="<?php echo "$url/Category/$lang/".urlencode($cat)."/"; ?>"><?php echo $cat; ?></a> > <?php echo $sub_cat; ?></h2> <p> <?php echo $description; ?> </p> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like layout="button_count" show_faces="false" width="170" font="verdana"></fb:like> <div id="related-wrap"> <h2><?php echo $sub_cat; ?> Products</h2> <?php $range_products = mysql_query("SELECT * FROM $table WHERE CATEGORY='$cat' AND SUB_CATEGORY='$sub_cat' AND display='1' ORDER BY sortID ASC"); while($row_range = mysql_fetch_array($range_products)) { $prodid = str_replace("/", "-", $row_range['PRODID']); $cat_link = urlencode($row_range['CATEGORY']); $sub_cat_link = urlencode($row_range['SUB_CATEGORY']); echo "<div class='related-products'>\n<a class='related-img' href='$url/Product/$lang/$cat_link/$sub_cat_link/$prodid/'>\n<img src='$img_loc/product-pages/Range-thmb/$prodid.jpg' width='120' height='120' /></a>\n"; echo "<h5>" . $row_range['PROD_TITLE'] . "</h5>\n"; echo "</div>\n"; } mysql_free_result($range_products); ?> </div> <div id="FAQ-wrap"><h2>Frequently Asked Questions</h2> <?php $QA_table = $lang . "_qanda"; if ($id=="") { $list_QA = mysql_query("SELECT * FROM $QA_table WHERE SUB_CATEGORY='$sub_cat' AND DISPLAY='1'") or die(); } else { $list_QA = mysql_query("SELECT * FROM $QA_table WHERE PRODID='$id' AND DISPLAY='1'") or die(); } while($row_QA = mysql_fetch_array($list_QA)) { echo "<div id='FAQ-QA'>"; echo "<h2 class='FAQ-question'>Q: ".$row_QA['QUESTION']."</h2>"; echo "<p class='FAQ-question'>A: ".$row_QA['ANSWER']."</p></div>"; } mysql_free_result($list_QA); ?> <div id="FAQ-question"> <h2 class="white">Got a question about the <span class="got-question-product"><?php echo $sub_cat; ?></span> </h2> </div> </div> </div> <div id="totem-menu-container"><?php include("./includes/search.php") ?> <?php include("./includes/totem.php") ?> </div> </div> </div> <!-- MAIN CONTENT OF PAGE BELOW HERE --> <!-- END MAIN CONTENT OF PAGE BELOW HERE --> <?php include("./footer.php") ?> <?php // open the cache file for writing $fp = fopen($cachefile, 'w'); // save the contents of output buffer to the file fwrite($fp, ob_get_contents()); // close the file fclose($fp); // Send the output to the browser ob_end_flush(); ?> I'm trying to create an online web editor. It works fine for opening and writing files on the same server where the web editor is hosted, but I want it to be able to get_file_contents, fopen and fwrite files on a remote server, logging in with ftp_connect and ftp_login. I've noticed the functions ftp_get and ftp_fget but I'd rather not create another local file, if possible I want to open the remote file directly into a <texarea> then save it directly back to the remote server. Is this possible? So far I just get errors... Here's an example of the code I'm trying to combine, to retrieve the contents of a file on a remote server and put them in a <textarea>: Code: [Select] <?php $conn = ftp_connect("ftp.domain.com"); ftp_login($conn, "username", "password"); ftp_pasv($conn, true); $filename='example.php'; // open file $fh = fopen($filename, "r") or die("Could not open file!"); // read file contents $datax = fread($fh, filesize($filename)) or die("Could not read file!"); $data=htmlspecialchars($datax); // close file fclose($fh); // close this connection ftp_close($conn); echo '<textarea cols="200%" rows="50">'.$data.'</textarea>'; ?> And another failed example: Code: [Select] <?php $filename='editor.php'; $fh = fopen("ftp://username:password@domain.com/example.php", "r") or die("Could not open file!"); $datax = fread($fh, filesize($filename)) or die("Could not read file!"); $data=htmlspecialchars($datax); fclose($fh); echo '<textarea cols="200%" rows="50">'.$data.'</textarea>'; ?> Hi again.... I'm working on a project that creates a profile page for the user (i.e. 'username.php') when they register. Because there are two ways to register, through Facebook and through the website itself, there has to be an if statement in this page that it crates as to which ID to use for that user. Because Facebook usernames are not unique, we must identify a user through their OAuth User ID which is a 10 digit number. When a user registers through the website itself, usernames are unique so their profile page can be ID'd by their username. Here's the code that creates that profile page: function createProfile($user) { $userFile = 'users/'.$result['oauth_uid'].'.php'; $fh = fopen($userFile, 'w') or die("can't open file"); $stringData = "<?php\n" . '$pageowner = "' . $result['oauth_uid'] . '";' . "\n" . 'include "profile.php";' . "\n?>"; fwrite($fh, $stringData); fclose($fh); } $user is the username passed to the function when it's called. Currently that is set to create a line of code in the new profile page ('userid'.php) that looks like this: <?php $pageowner = "100001745088506"; include "profile.php"; ?> I want to add an IF to that page that follows this structu if oauth_provider == facebook { $pageowner = "oauth_uid" } else { $pageowner = username } But I don't know how to write that he $stringData = "<?php\n" . '$pageowner = "' . $result['oauth_uid'] . '";' . "\n" . 'include "profile.php";' . "\n?>"; to make it show up in the page it creates. I want that if statement to be written IN the page that is created. I just don't know the syntax well enough yet to do that. Would somebody help me out or point me in the right direction? Thanks! it doesnt write into the files, the file is created and everything and how would i echo the whole file? Code: [Select] if (isset($_POST['submit'])) { $firstname = ($_POST['firstname']); $lastname = ($_POST['lastname']); include ("cookieusername.php"); $filename = "***/$username.info.php" or exit("Unable to open file!"); $handle = @fopen($filename, 'x+')or die(mysql_error()); $content = "lololo"; @fwrite($handle, $content)or die(mysql_error()); @fclose($filename); } Code: [Select] function convert_youtube($code,$code1) { $youtube_count++; return '<embed src="http://'.$code.'youtube.com/v/'.$code1.'" type="application/x-shockwave-flash" wmode="transparent" width="512" height="313" allowfullscreen="true" />'; } echo $youtube_count; im trying to echo it out, i have like 5 flash videos on the bbcode parser: Code: [Select] $RegEx = '%(\[quote(?:=[^\]]*)\].*?)?\[youtube\]http\://(.*?)youtube\.com/watch\?v\=(.*?)\[/youtube\](.*?\[/quote\])?%ie'; if(preg_match_all($RegEx, $text, $matches,PREG_SET_ORDER)){ foreach($matches as $match){ if(!empty($match[0]) && empty($match[1]) && empty($match[4])){ $text = str_replace($match[0], convert_youtube($match[2],$match[3]), $text); }else{ $url = sprintf('http://%syoutube.com/watch?v=%s',$match[2],$match[3]); $text = str_replace($match[0], sprintf('%s<a href=\'%s\' target=\"_blank\">%s</a>%s',$match[1],$url,$url,$match[4]), $text); } } } if i do "echo "hey";" it works but not any variables.. zzzzzzzzzzzzzzzzz Hi guys, in code below I have a section where users can check seat avillability, however it shows the seats taken but it doest say the seats available, can u help me find out whats wrong? thanks in advance guys this is the line below $checkavailability=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND ride_id='$ride_id'"); while($row=mysql_fetch_array($checkavailability)) { $takenseats=$row['seat_no']; if (mysql_num_rows($checkavailability)>=1) { echo "<table>"; echo " <td>Seat No ".$takenseats." is taken</td> "; } else{ echo " <td>Seat No ".$takenseats." is Available</td> "; } } echo "</table>"; } ?> full code below: <?php session_start(); include ("includes/db.php"); include ("includes/function.php"); //authentication if (loggedin()==FALSE) { Header("Location: login.php"); exit(); } //username session $_SESSION['username']=='$username'; $username=$_SESSION['username']; echo "Welcome, " .$_SESSION['username']."!<p>"; //get details from user table to be passed to page(text fields) $getdetails=mysql_query("SELECT * FROM users WHERE username='$username'"); while($row = mysql_fetch_array($getdetails)) { $users_id=$row['id']; $first_name=$row['first_name']; $last_name=$row['last_name']; $email=$row['email']; } /////////////////////////////////////// //****************************// //post starts here if (isset($_POST['next']) && $_POST['next']) { $myfirstname = addslashes(strip_tags($_POST['firstname'])); $mylastname = addslashes(strip_tags($_POST['lastname'])); $myemail = addslashes(strip_tags($_POST['email'])); $mybookingdate = addslashes(strip_tags($_POST['datetime'])); $mytime = addslashes(strip_tags($_POST['time'])); $myseatnumber = addslashes(strip_tags($_POST['seatnumber'])); $ride_id=1; //check if booking exists $checkbooking=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND seat_no='$myseatnumber'"); if (mysql_num_rows($checkbooking)>=1) { echo "Seat No $myseatnumber For $mybookingdate at $mytime has been already taken, Please try a different seat, time or date"; } else { $checktotoal=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime'"); if (mysql_num_rows($checkbooking)>=48) { echo "We are fully book for this time and date, please choose different time/date to continue your booking"; } //pass the variables here } } if (isset($_POST['availability']) && $_POST['availability']) { $mybookingdate = addslashes(strip_tags($_POST['datecheck'])); $mytime = addslashes(strip_tags($_POST['timecheck'])); $myseatnumber = addslashes(strip_tags($_POST['seatnumbercheck'])); $ride_id=1; $checkavailability=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND ride_id='$ride_id'"); while($row=mysql_fetch_array($checkavailability)) { $takenseats=$row['seat_no']; if (mysql_num_rows($checkavailability)>=1) { echo "<table>"; echo " <td>Seat No ".$takenseats." is taken</td> "; } else{ echo " <td>Seat No ".$takenseats." is Available</td> "; } } echo "</table>"; } ?> <html> <head> <link type="text/css" href="css/smoothness/jquery-ui-1.8.6.custom.css" rel="stylesheet" /> <script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="includes/jquery-ui-1.8.6.custom.min.js"></script> <script type="text/javascript"> $(function() { $('#datetime').datepicker({ dateFormat: 'dd.mm.yy' }); }); $(function() { $('#datecheck').datepicker({ dateFormat: 'dd.mm.yy' }); }); </script> </head> <body> <table width="665" border="0"> <tr> <td width="372"><form name="booking" method="post" action=""> <p>BOOK NOW <p> First Name:<br /> <input type="text" name='firstname' value="<? echo "$first_name";?>"> <p>Last Name:<br /> <input type="text" name='lastname' value="<? echo "$last_name";?>"> <p>Email:<br /> <input type="text" name='email' value="<? echo "$email";?>"> <p>Choose a Date:<br /> <input type="text" name='datetime' id="datetime"> </p> <p> Select a Time:<br/> <select name='time'> <option value="9:00">9:00 <option value="9:07">9:07 <option value="9:14">9:14 <option value="9:21">9:21 <option value="9:28">9:28 <option value="9:35">9:35 <option value="9:42">9:42 <option value="9:49">9:49 <option value="9:56">9:56 <option value="10:03">10:03 <option value="10:10">10:10 <option value="10:17">10:17 <option value="10:24">10:24 <option value="10:31">10:31 <option value="10:38">10:38 <option value="10:45">10:45 <option value="10:52">10:52 <option value="10:59">10:59 <option value="11:02">11:02 <option value="11:09">11:09 <option value="11:16">11:16 <option value="11:23">11:23 <option value="11:30">11:30 <option value="11:37">11:37 <option value="11:44">11:44 <option value="11:51">11:51 <option value="11:58">11:58 </select> </p> <p> Select Seat Number:<br/> <select name='seatnumber'> <option value="1">Seat 1 <option value="2">Seat 2 <option value="3">Seat 3 <option value="4">Seat 4 <option value="5">Seat 5 <option value="6">Seat 6 <option value="7">Seat 7 <option value="8">Seat 8 <option value="9">Seat 9 <option value="10">Seat 10 <option value="11">Seat 11 <option value="12">Seat 12 <option value="13">Seat 13 <option value="14">Seat 14 <option value="15">Seat 15 <option value="16">Seat 16 <option value="17">Seat 17 <option value="18">Seat 18 <option value="19">Seat 19 <option value="21">Seat 20 <option value="22">Seat 22 <option value="23">Seat 23 <option value="24">Seat 24 <option value="25">Seat 25 <option value="26">Seat 26 <option value="27">Seat 27 <option value="28">Seat 28 <option value="20">Seat 29 <option value="30">Seat 30 <option value="31">Seat 31 <option value="32">Seat 32 <option value="33">Seat 33 <option value="34">Seat 34 <option value="35">Seat 35 <option value="36">Seat 36 <option value="37">Seat 37 <option value="38">Seat 38 <option value="39">Seat 39 <option value="40">Seat 40 <option value="41">Seat 41 <option value="42">Seat 42 <option value="43">Seat 43 <option value="44">Seat 44 <option value="45">Seat 45 <option value="46">Seat 46 <option value="47">Seat 47 <option value="48">Seat 48 </select> <p> <input type='submit' name='next' value='Next Step'> </form></td> <td width="283"> <form name="booking" method="post" action=""> <p>Check Seat Availability<br /> <p><br /> <p>Choose a Date:<br /> <input type="text" name='datecheck' id="datecheck"> <p> Select Seat Number:<br/> <select name='seatnumbercheck'> <option value="1">Seat 1 <option value="2">Seat 2 <option value="3">Seat 3 <option value="4">Seat 4 <option value="5">Seat 5 <option value="6">Seat 6 <option value="7">Seat 7 <option value="8">Seat 8 <option value="9">Seat 9 <option value="10">Seat 10 <option value="11">Seat 11 <option value="12">Seat 12 <option value="13">Seat 13 <option value="14">Seat 14 <option value="15">Seat 15 <option value="16">Seat 16 <option value="17">Seat 17 <option value="18">Seat 18 <option value="19">Seat 19 <option value="21">Seat 20 <option value="22">Seat 22 <option value="23">Seat 23 <option value="24">Seat 24 <option value="25">Seat 25 <option value="26">Seat 26 <option value="27">Seat 27 <option value="28">Seat 28 <option value="20">Seat 29 <option value="30">Seat 30 <option value="31">Seat 31 <option value="32">Seat 32 <option value="33">Seat 33 <option value="34">Seat 34 <option value="35">Seat 35 <option value="36">Seat 36 <option value="37">Seat 37 <option value="38">Seat 38 <option value="39">Seat 39 <option value="40">Seat 40 <option value="41">Seat 41 <option value="42">Seat 42 <option value="43">Seat 43 <option value="44">Seat 44 <option value="45">Seat 45 <option value="46">Seat 46 <option value="47">Seat 47 <option value="48">Seat 48 </select> <p> </p> <p> Select a Time:<br/> <select name='timecheck'> <option value="9:00">9:00 <option value="9:07">9:07 <option value="9:14">9:14 <option value="9:21">9:21 <option value="9:28">9:28 <option value="9:35">9:35 <option value="9:42">9:42 <option value="9:49">9:49 <option value="9:56">9:56 <option value="10:03">10:03 <option value="10:10">10:10 <option value="10:17">10:17 <option value="10:24">10:24 <option value="10:31">10:31 <option value="10:38">10:38 <option value="10:45">10:45 <option value="10:52">10:52 <option value="10:59">10:59 <option value="11:02">11:02 <option value="11:09">11:09 <option value="11:16">11:16 <option value="11:23">11:23 <option value="11:30">11:30 <option value="11:37">11:37 <option value="11:44">11:44 <option value="11:51">11:51 <option value="11:58">11:58 </select> <p> <input type='submit' name='availability' value='Check Availability'> </form> </td> </tr> </table> <p> </body> </html> i want to create function that calculate worker that attend 6 days activity on year B and group it by their gred. so i use this coding but it give wrong result Code: [Select] function countSix($a,$f) { $sql = "SELECT * FROM staf_info INNER JOIN aktiviti_staf ON staf_info.id=aktiviti_staf.id INNER JOIN aktiviti ON aktiviti_staf.id_aktiviti=aktiviti.id_aktiviti WHERE staf_info.id_kumpulan = '".$a."' AND year(tarikh_awal) LIKE '%".$f."'"; $query= mysql_query($sql) or die("Error: " .mysql_error()); $row=mysql_num_rows($query); $num=1; $f=0; if($row!=0) { while( $data=mysql_fetch_assoc($query)) { $b=$data['bil_hari']+$data['hari_kursus']; if($b == 6) { $e = countStaf($data['id'],$data['id_aktiviti']); $f = $f + $e; } } } return $f; } function countStaf($c,$d) { $sql = "SELECT COUNT(*) AS STAFCOUNT FROM aktiviti_staf WHERE id = '".$c."' AND id_aktiviti = '".$d."'"; $query= mysql_query($sql) or die("Error: " .mysql_error()); $row=mysql_num_rows($query); $result = mysql_fetch_array($query); return $result['STAFCOUNT']; } i can't seem to find the error.. help me please!! I have a quite old book about database applications, and i got a problem with it. I have this page, create_entry.php Code: [Select] <?php include("dbconnect.php"); if ($submit == "Sign") { $query = "insert into DA_guestbook(name, location, email, url, comments) values ('$name', '$location', '$email', '$url', '$comments')"; mysql_query($query) or die (mysql_error()); ?> <h2>Thanks!!</h2> <h2><a href="view.php">View my guestbook!</a></h2> <?php } else { include("sign.php"); } ?> and i got this page named sign.php Code: [Select] <h2>Sign my guestbook</h2> <form method="post" action="create_entry.php"> <b>Name:</b> <input type="text" size="40" name="name"> </br> <b>Location:</b> <input type="text" size="40" name="location"> </br> <b>Email:</b> <input type="text" size="40" name="email"> </br> <b>Home Page Url:</b> <input type="text" size="40" name="url"> </br> <b>Comments:</b> <textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea> </br> <input type="submit" name="submit" value="Sign"> <input type="reset" name="reset" value="Start Over"> </form> When i open create_entry.php then sign.php is indeed shown up. However when i send, it brings me to the same page with no Thanks!! etc. Also nothing gets inserted in the database. Hope i explained well enough I have the following code, and for some reason the nl2br() function doesnt work anymore it did until i added the pred_replace part: $topic = $_POST['topic']; $message = $_POST['message']; $board = $_POST['board']; $topic = stripslashes($topic); $message = stripslashes($message); $board = stripslashes($board); $topic = mysql_real_escape_string($topic); $message = mysql_real_escape_string($message); $board = mysql_real_escape_string($board); $message = nl2br($message); $message = preg_replace("/\[b\](.*)\[\/b\]/Usi", "<b>\\1</b>", $message); $message = preg_replace("/\[u\](.*)\[\/u\]/Usi", "<u>\\1</u>", $message); $message = preg_replace("/\[i\](.*)\[\/i\]/Usi", "<i>\\1</i>", $message); $message = preg_replace("/\[center\](.*)\[\/center\]/Usi", "<center>\\1</center>", $message); $message = preg_replace("/\[right\](.*)\[\/right\]/Usi", "<p align=right>\\1</p>", $message); $message = preg_replace("/\[url=http://(.*)\](.*)\[\/url\]/Usi", "<a href=\"\\1\">\\2</a>", $message); $message = preg_replace("/\[img=(.*)\]/Usi", "<img src=\"\\1\">", $message); $message = preg_replace("/\[profile=(.*)\](.*)\[\/profile\]/Usi", "<a href=\"index.php?step=profile&profile=\\1\">\\2</a>", $message); $message = preg_replace("/\[quote](.*)\[\/quote\]/Uis", "<div>Quote:</div><div style=\"border:solid 1px;\">\\1</div>", $message); Hi, Im using a button to delete each entry from my database, however it doesnt. I have tried it with linking to a delete page and works fine with the same mysql query, but i need to hve the button to delete and not a URL. Can someone please help me to see what is wrong? thanks in advance guys <?php include ("../include/global.php"); include ("../include/function.php"); if (loggedin()==FALSE) { Header("Location: ../login.php"); exit(); } $_SESSION['username']=='$username'; $username=$_SESSION['username']; $getid=mysql_query("SELECT id FROM users WHERE username='$username'"); while($row=mysql_fetch_array($getid)) { $usersid=$row['id']; } if (isset($_POST['add']) && $_POST['add']) { $subject = addslashes(strip_tags($_POST['subject'])); $text = addslashes(strip_tags($_POST['text'])); $update=mysql_query("INSERT INTO users_notes (user_id, subject, note) VALUES ('$usersid','$subject','$text')"); } if (isset($_POST['remove']) && $_POST['remove']) { $delete=mysql_query("DELETE FROM users_notes WHERE user_id='$usersid' AND AND id='$id'"); } ?> <html> <head> <script type="text/javascript" src="/js/jquery.js"></script> <script type="text/javascript" src="/js/jquery.validate.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#form").validate(); }); </script> </head> <body> <p>You are logged in! <a href="logout.php">Log out</a> </p> <p> </p> <p><td><? $getmsg=mysql_query("SELECT * FROM users_notes WHERE user_id='$usersid'"); while($row=mysql_fetch_array($getmsg)) { $id=$row['id']; $msgsubject=$row['subject']; $msgnotes=$row['note']; echo"<table width='800' border='1'>"; echo" <tr> <td width='50'>".$msgsubject."</td> <td width='50'>".$msgnotes."</td> <td width='40'><form id='form' method='post' action=''> <input type='submit' name='remove' value='remove' /> </form></td> <td> </td> </tr> "; } echo "</table>"; ?> </td> </p> <p> </p> <form action="" method="POST" id="form"> <p> Subject: <br/> <input type="text" name="subject" class="required"> </p> <p> Your Note: <br/> <textarea name="text" id="text" cols="45" rows="15" class="required"></textarea> </p> <p> <input type="submit" name="add" value="Add" > </p> </form> </body> im trying to connect to our office server by remote desktop.. but when i do it..alot of error came out from my index.php and counter.php.. does anyone ever experience these problems? what should i do.. i made a submitter, that workes:
<?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO aktiviteter (`title`, `firma`, `beskrivelse`, `information`, `pris`, `rabat`, `adresse`, `by`, `postnummer`, `telefon`, `hjemmeside`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['title']), mysqli_real_escape_string($con, $_POST['firma']), mysqli_real_escape_string($con, $_POST['beskrivelse']), mysqli_real_escape_string($con, $_POST['information']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['rabat']), mysqli_real_escape_string($con, $_POST['adresse']), mysqli_real_escape_string($con, $_POST['by']), mysqli_real_escape_string($con, $_POST['postnummer']), mysqli_real_escape_string($con, $_POST['telefon']), mysqli_real_escape_string($con, $_POST['hjemmeside']) ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "Aktiviteten er uploaded"; mysqli_close($con);but then i changed a few parameters and now it doesnt. i cant figure out why <?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO menus (`navn`, `kommentar`, `pris`, `target`) VALUES ('%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['navn']), mysqli_real_escape_string($con, $_POST['kommentar']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['target']), ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "menuen er uploaded"; mysqli_close($con);can anyone spot the mistake i made? page 1 is this session_start(); include 'db.php'; $email = $_POST['email']; $password = $_POST['password']; $email = stripslashes($email); $password = stripslashes($password); $email = mysql_real_escape_string($email); $password = mysql_real_escape_string($password); $sql="SELECT * FROM directory WHERE email='$email' and password='$password' "; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ $wtf="SELECT * FROM directory WHERE email='$email' and password='$password' "; while($row = mysql_fetch_array($wtf)) { $fname = $row['fname']; $lname = $row['lname']; $address = $row['address1']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; } $_SESSION['user'] = $email; $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['address1'] = $address; $_SESSION['city'] = $city; $_SESSION['state'] = $state; $_SESSION['zip'] = $zip; $_SESSION['status'] = "1"; page two is just: only the user and status works. session_start(); echo $_SESSION['user'] ; echo $_SESSION['fname'] ; echo $_SESSION['lname'] ; echo $_SESSION['address1']; echo $_SESSION['city'] ; echo $_SESSION['state'] ; echo $_SESSION['zip']; echo $_SESSION['status']; why is that not working In Firefox and Google Crome my code works correct, but in IE it doesnt. The problem is that before or after loading a page in IE, $_SESSION is unsetted. If i set $_SESSION['online'] = 1, then after reloading the page then print_r($_SESSION) outputs nothing. if ($btn){ if((!empty($filename)) && ($error == 0)) { if (($filetype == "image/jpeg" || $filetype == "image/jpg" || $filetype == "image/gif" || $filetype == "image/png") && ($filesize < 4508876)) { $moving_flag = true; $moving_msg = "Your image has been uploaded!"; } else { $upl_error_msg = "Error: Only jpg/gif/png images under 4Mb are accepted for upload"; $upl_error_flag = true; } } else { $upl_error_msg = "Error: No file uploaded"; $upl_error_flag = true; } } Why the above code wont work on IE and wont show me "Your image has been uploaded!" message when i have a valid type and size? it works on chrome and FF Hi I am trying to incorporate a login form on my main page from WHMCS but nothing happens I did an include ('login2.php'); and in that login2.php here is the code: Code: [Select] <?php echo date("l F jS Y "); require("./billing/dbconnect.php"); require("./billing/includes/functions.php"); require("./billing/includes/clientareafunctions.php"); if ($_SESSION['uid']) { $result = mysql_query("SELECT firstname,lastname FROM tblclients WHERE id=" . $_SESSION['uid'] . ""); $data = mysql_fetch_array ($result); echo "<hr/><strong>Welcome Back</strong><br>"; echo "<strong>{$data['firstname']}</strong> "; echo "<strong>{$data['lastname']}</strong><br><br>"; echo "<br><br><form method=post action=http://store.crytell.com/billing/logout.php><input type=submit class=submitbutton value=Logout /></form>"; } else { echo '<form method="post" action="http://store.crytell.com/billing/dologin.php?goto=clientarea"> <input type="hidden" name="token" value="##removed##" /> Email Address: <input type="text" name="username" size="50"><br> Password: <input type="password" name="password" size="20"><br> <input type="submit" value="Login"> </form>'; } ?> when I go directly to the login script it works but when I include it in my homepage nothing happens any help? |