331 Posted Topics
Re: > $result1=mysql_query($sql1); change it to: $result1=mysql_query($sql1) or die(mysql_error($sql1)); the query is failing or not matching any rows if($_SERVER["REQUEST_METHOD"] == "POST"){ $myusername1=addslashes($_POST['username']); $mypassword1=addslashes($_POST['password']); $ip = $_SERVER["REMOTE_ADDR"];//should still validate this in case $pass1 = md5($mypassword1);//could use $hash1 = hash('sha256', $salt . $mypassword1);//(more secure) $sql1="SELECT * FROM stamboom_admin WHERE username='$myusername1' and password='$pass1' and … | |
Re: <?php $languages = array('en'=>'blabla 0','fi'=>'blabla 1','et'=>'blabla 2'); $langPicked = false; foreach($languages as $k=>$v){ if($_COOKIE['content'] == $k){ $lang = $k; $langPicked = true; } } if($langPicked === false){ $lang = 'en'; } //$lang == 'en' || 'fi' || 'et' //$languages[$lang] == 'blabla 0' || 'blabla 1' || 'blabla 2' ?> | |
![]() | Re: How is that checkout data stored? Sorry in advance if code tags don't work Here is a demo check out: QTY--items - Price - Total 6 apple - $0.89 (each) = $5.34 6 orange - $0.89 (each) = $5.34 6 Kiki - $0.89 (each) = $5.34 8 tomato - $0.89 … |
Re: you will need to find the http request javascript uses to pull the post, though i'm wondering if i should help or not | |
Re: try making a second page called sessiondump.php <?php session_start(); var_dump($_SESSION); ?> and navigate to that on the same server after submitting the form veedeoo posted. you need to make sure session_start() is called at the start on any page you want session vars, then they are available in the $_SESSION … | |
Re: can't read what the top table is called but something like this: $Q = "SELECT * FROM `toptable`"; $R = mysql_query($Q); if($R !== false){ $ularray = array(); while($row = mysql_fetch_assoc($R)){ $ularray[$row['FKGMainId']][] = $row; } }else{ die('no data: '.mysql_error()); } foreach($ularray as $k=>$v){ echo "{$k}<ul>\r\n"; foreach($v as $li){ echo "<li>{$li['QuestionAnswerText']}</li>\r\n"; } … | |
Re: yes http://davidwalsh.name/execute-http-post-php-curl use it to post the vars to the login script(the url in the form action='process.php') | |
Re: > <select name='name' class="required form-select" title="Please select customer name" onChange='javascript:form_submit();'> the form should only be submitting when you change the option on the select box, are you supposed to be able to enter data after selecting it? if you are this method won't work, you should just use the submit … | |
Re: as far as i know you have to loop, thats exactly what repeating something is. urtrivedi has done a good example of recursion, its basically long hand of doing what `while($i > 1)` does. If you don't want a loop type it out 100 times | |
Re: just to add a little - If you want a way of generating many dates without having to type them all out use strtotime: $i = 0; while($i <= 60){ $date_Array[] = date("Y-m-d",strtotime("-$i day")); $i++; } [strtotime()](http://php.net/manual/en/function.strtotime.php) | |
![]() | Re: somepage.php <?php $pagedata = array(); $pagedata['title'] = 'Test'; $pagedata['cssfile'] = 'template1.css'; require_once('template1.php'); ?> template1.php <html> <head> <title><?php echo $pagedata['title'];?></title> <link type='text/css' rel='stylesheet' href='<?php echo $pagedata['cssfile'];?>'> </head> <body> <div style='background-color:#ccc;'></div> </body> </html> Pretty simplistic but it lets you switch between templates rather easy |
Re: 3 equals checks that the 2 variables have the same value AND type(strict) 2 equals just checks that the value matches(loose) data coming from post and get vars come in a a string eg. page.php?quantity=1 <?php if($_GET['quantity'] == 1){ echo 'loose match: integar 1<br/>'; } if($_GET['quantity'] === 1){ echo 'strict … | |
Re: if(ctype_digit($_GET['id'])){ $id = $_GET['id']; }else{ $id = 0; } $query="SELECT * FROM srots where id = {$_GET['id']}"; $result=mysql_query($query); if($result !== false){ $data = mysql_fetch_assoc($result); var_dump($data); }else{ echo 'bad id'; } | |
Re: I wouldnt create a website in flash unless you do something really fancy, treat flash more like a fancy image or promotion that has a backup or doesn't matter if they can't view it. Generally when you make it the flash has some default thing to show such as the … | |
Re: Heres something to start you off: <?php if(isset($_POST['facebookaccount'])){ $acc = $_POST['facebookaccount']; }else{ $acc = false; } ?> <html> <body> <form action='post'> <table BORDER="0"> <tr> <td>facbook account :</td> <td><input type="text" name="facebookaccount" maxlength="50"/></td> <td><input type="SUBMIT" name="save1" value="save"/></td> </tr> </table> </form> <?php if($acc !== false){ echo "http://www.facebook.com/{$acc}"; } ?> </body> </html> Heres a … | |
Re: > $fgmembersite->CheckLogin() whats this object? that needs to have a method to get the currently logged in users user id - then use that to inesrt the user id of the person who uploaded the file eg. $userData = $fgmembersite->getUserData(); function getUserData(){ //$sql = "select * from users where token … | |
Re: The way you did it seemed pretty much fastest. I think latest might be getting set too soon, could it be set to only set latest to 1 once it has been sent? I just ended up with this SELECT * FROM tblp p WHERE ver = (SELECT MAX(ver) FROM … | |
Re: this is a backtick ` it has a different meaning SELECT `username`, `password`, `fullname`, `course`, `year`, `status` From `account_student` WHERE `id` = '6' they go around database,table and column names only to specifically say it is one, using ' will tell it they are strings | |
Re: > echo '<script>location.href="index.php";</script>' ; why not just do `header('Location: index.php");` if you are echoing it out? There should be a point in your js where the login succeeds and redirect then: messageDiv.innerHTML = req.responseText; if(req.responseText == 'Success'){window.location = 'index.php';} i always thought it was window.location, since your login is javascript … | |
Re: > if(isset($_SESSION['u_name'])) return $_SESSION['u_name']; > else if(isset($_COOKIE['u_name'])) return $_COOKIE['u_name']; is it possible $_SESSION['u_name'] could be set to ''? | |
Re: > $success = mysql_query($final) or die(mysql_error()); > echo "<table><tr>"; > foreach($_POST['fields'] as $f){ > echo "<th>".$f."</th>"; > } > echo "</tr>"; > $i=0; > while($row = mysql_fetch_assoc($success)){ > echo "<tr>"; > foreach($row as $r){ > echo "<td>".$r."</td>"; > $i++; > } > echo "</tr>"; > } > echo "</table>"; That … | |
Re: mysql_query("UPDATE table SET status = 1 WHERE id = '". $_POST['repid']."'",$c2) or die(mysql_error()); missing the closing double quote! <form method="post"> just change each form's method to post and update the queries like fobos wrote and that should work You may want to add `die(mysql_error($c2));` as if there is one and … | |
Re: The 2 tables in your example don't sound connected? you need to tell mysql what to join the 2 tables on eg. SELECT username,prod_id,prod_name FROM users LEFT JOIN products on users.uid = products.uid I think mysql will default use the primary keys, if they dont match it can't join so … | |
Re: Looks pretty insane, only thing i can think of: > private function convertToListItem( $heading, $path = "", $isHeading = false, $isSubMenu ) I may not be thinking of php but i thought optional parameters always had to be last in the function declaration and use `var_dump();` to see whats actually … | |
Re: `mysql_fetch_array()` pulls the resource as an associative array and as a numbered array, try changing it to `mysql_fetch_assoc()` | |
Re: you mean: #content ul li{ width:145px; } ? | |
| |
Re: speed, ease of use & simplicity are good goals to aim for. Interactive media would make me think flash or a web app. But its a pretty broad area what exactly do you need to code for your exam? jquery and javascript offer alot of interactivity on websites so i … | |
Re: > $str &= $_POST['txt'.$i]. $str .= $_POST['txt'.$i]; not sure what &= does You could also just loop through the $_POST array $str = ''; foreach($_POST as $k=>$v){ if(substr($k,0,3) == 'txt'){ $str .= $v; } } echo $str; | |
Re: Hows this work? <?php ///----------------------------- /// Inserting data into database ///----------------------------- include 'connect_db.php'; include 'newheader.php'; function sanitize_data($data) { $data = array_map('trim',$data); $data = array_map('strip_tags',$data); $data = array_map('htmlspecialchars',$data); $data = array_map('mysql_real_escape_string',$data); return $data; } $post = sanitize_data($_POST); if ($_POST['searchID']) { $searchById = "SELECT * FROM tc_tool.forms WHERE doc_id = '$doc_id' LIMIT … | |
Re: or SELECT user, pass, email, count(*) as `num_accounts` FROM members WHERE mem_status <>'T' GROUP BY email ORDER BY email asc"; | |
Re: $to = "myemail@domain.com"; $subject = "Contact Form Posting"; $additional_headers = "From: ".$_POST['name']." <".$_POST['email']."> \r\n"; //use . to concatenate strings/variables together $message = $_POST['msg']; //no $ in front of mail, it's a function if(mail($to, $subject, $message,$additional_headers)){ echo "We've recived your contact information"; } else { echo "ERROR"; } | |
Re: DELETE FROM users WHERE user_status = 0 AND date_signed_up < DATE_SUB(NOW(), INTERVAL 2 DAY); or UPDATE users SET `deleted` = 1 WHERE user_status = 0 AND date_signed_up < DATE_SUB(NOW(), INTERVAL 2 DAY); | |
Re: Ardav is right, mysql won't be able to make proper use of indexes either ALTER TABLE `dates` ADD COLUMN `start_date2` DATE NULL AFTER `start_date`, ADD COLUMN `end_date2` DATE NULL AFTER `end_date`; UPDATE `dates` SET start_date2 = STR_TO_DATE(start_date,'%m/%d/%Y'), end_date2 = STR_TO_DATE(end_date,'%m/%d/%Y'); If its not possible to change it your query would … ![]() | |
Re: => is used for arrays, denoting key/value pairs eg. $array = array('item1'=>'apple','item2'=>'pear'); foreach($array as $key=>$value){ echo $key.' = '.$value; } -> is used for object orientated processing (OOP) eg. $shoppingcart = new basket(); $shoppingcart->addItem('apple'); $shoppingcart->displayBasket(); | |
Re: Just to confirm it should be like this: ($username maybe not set?) page1.php <? session_start(); $_SESSION["username"] = 'Testing'; echo '$_SESSION["username"] set to Testing'."<br/>\r\n"; echo "<a href='page2.php'>page 2</a>"; ?> page2.php <?php session_start(); var_dump($_SESSION["username"]); //phpinfo(); ?> If it's not working uncomment the `phpinfo();` that will tell you a list of the php … | |
Re: > <a href='viewnotice.php?nid=$nid'>$ntitle</a> That is a GET variable not POST $noticeid=$_GET['nid']; | |
Re: hey, your select query isn't pulling the id > $db->query(" > SELECT COUNT(id) AS total, > login > FROM users > WHERE login = '$login' > AND password = '$password' > "); $db->query(" SELECT COUNT(id) AS total, id, login FROM users WHERE login = '$login' AND password = '$password' "); | |
Re: Theres 2 sides, one is the php ini setting: set_time_limit($seconds); That will override that, the other side is your server script timeout such as cgi script timeout on IIS, you have to allow it more time but im not sure how to set that one and completely depends on what … | |
Re: im no linux genius but i connect to mysql through putty using the command: mysql -uuser -ppassword no spaces after -u or -p the user is usually root Can you not get onto mysql through phpmyadmin on plesk? | |
Re: I recently improved a database we had in a similar setup, we had a table for every client which held all the relevant data for the company, this was setup over 2 years ago now and we were up to over 500 tables! the lack of scalability starting to show … | |
Re: Will the iconv() function solve that for you? http://www.php.net/manual/en/function.iconv.php ![]() | |
Re: why not just put it at the top of index.php? I personally don't like using htaccess www.example.com/index.php <?php if(ISSET($_GET['id']) && ctype_alnum($_GET['id'])){ header("Location: http://www.example.com/{$_GET['id']}"); } | |
Re: its probably the file functions? Take out the @ symbols - they suppress errors My php page: <?php echo '<a href="form1.html">sign my guest book</a>'; $guestbook = fopen("sign.txt", "r"); while (!feof($guestbook)) { echo "\n" . fgets($guestbook) . "<br />"; } fclose($guestbook); $datetime=date("y-m-d h:i:s"); $data = "<h1>" . $datetime . " \n" … | |
Re: I doubt google places has been setup to recieve auto form submission data from external websites, you could get the data from them then fill it in yourself - its not ideal though cause these reviews will all come from the same ip which is a common check on reviews … | |
Re: > <?php > if ( is_singular() ) { > global $wp_query; > $postid = $wp_query->post->ID; > $ad468 = get_post_meta($postid, 'ad468_post', true); > if ( !$ad468 && get_option('stream_ad468') == 'yes' ) { > $ad468 = get_option('stream_ad468_code'); > } > } > if ( !is_singular() && get_option('stream_ad468') == 'yes' ) { > … | |
Re: >veedoo, wanna ask you something....can this code be done purely in php(not using javascript) >thanks As far as i know you can't copy what veedeoo has done in his demo above, thats client side scripting - css will be the closest you can get to interactivity on the webpage without … | |
Re: change $result= mysql_query($query); to: $result= mysql_query($query) or die(mysql_error()); | |
Re: your edit link is wrong? echo "<td align=center>"."<a href=delete.php?Code=".$row['Code']."><input type='image' src=erase.ico></a>"."</td>"; echo"<td align=center>"."<a href='home_edit.php?Code=$code'> <input type='image' src=edit.png></a>"."</td></tr>"; it says `$code` instead of `$row['Code']` | |
Re: thats a php compile error, you have some bracket/quote/semicolon missing somewhere. it will be on or before line 83 probably not too far back |
The End.