-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Parse error: syntax error, unexpected T_DOUBLE_ARROW
Ch0cu3r replied to shaneHoll's topic in PHP Coding Help
The => here if($balance=>$amount){ should be >= -
If the id is from the url then you need to use $_GET['id'] not $id
-
Php Forum Code Not Displaying the Forum
Ch0cu3r replied to IlaminiAyebatonyeDagogo's topic in PHP Coding Help
Remove $result from mysql_affected_rows($result) I always forget it requires the link resource not the result resource. Try changing <? echo to <?php echo The <? ?> tags may not work if a setting called short_open_tag is enabled in the php.ini -
Php Forum Code Not Displaying the Forum
Ch0cu3r replied to IlaminiAyebatonyeDagogo's topic in PHP Coding Help
You need to also check that the query actually added a row to the table using mysql_affected_rows. In add_topic.php use this code when checking the query has added the topic to the table. $sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')"; $result=mysql_query($sql); if($result){ if(mysql_affected_rows($result)) { echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; } else { echo 'Topic not added to table'; } } else { echo "ERROR"; } You will also want to be santizing your user input before your use it in your queries. Using raw $_POST data in your SQL queries will lead to SQL injection vulnerabilities either use mysql_real_escape_string or upgrade your code to use the MySQL Improved function library and use prepared queries to help prevent SQL injection attacks. Also note the standard mysql function library is deprecated and could soon be removed, so I recommend you change to mysqli now. -
before the while loop add $i = 0; Then when displaying the comments you'd use this code if($i % 2 == 0) { // html code for displaying comment with avater on the left } else { // html code for displaying comment with avater on the right } $i++;
-
What does <tr class="alt"> mean when creating an HTML table
Ch0cu3r replied to spence911's topic in PHP Coding Help
alt is the name of the CSS class definition. Check your CSS stylesheet to see what styles are applied for that class.- 3 replies
-
- html
- html table
-
(and 1 more)
Tagged with:
-
Unable to add some logic to support system of site
Ch0cu3r replied to r3wt's topic in PHP Coding Help
Ok I didn't explain what QuickOldCar code was sctually doing, if (isset($_POST['subject']) && isset($_POST['post']) && trim($_POST['subject']) != '' && trim($_POST['post']) != '' ) { It is checking to make sure the post and subject exist in the $_POST and then is trimming their values of white space. It then checks to make sure the remaining value is not empty. This stops someone from entering just spaces into the post and submit fields. -
I would not recommend chmod 777 as solution. This value gives everyone read and write permissions. I am inexpedience with linux file permissions but I know this value should never be used, especially for files on a webserver.
-
Yea I get the same result. However if I encase the bitwise or operation in parentheses then I get the correct output. $_DB[DIR] = Directory_database DF_DIR_MADE = 2 DF_V5 = 128 SELECT * FROM Directory_database WHERE ( `flags` & 130 ) = 2 ORDER BY `id` ASC;
-
Unable to add some logic to support system of site
Ch0cu3r replied to r3wt's topic in PHP Coding Help
Trim removes white space from the beginning and end of a string value. The first elseif should be an if. if (isset($_POST["subject"]) && isset($_POST["post"])) { $post = mysql_real_escape_string(strip_tags($_POST["post"])); $uid = $loggedInUser->user_id; $posted = date("m/d/y g:i"); $subject = mysql_real_escape_string(strip_tags($_POST["subject"])); if (strlen($post < 30)) { echo "<p class='notify-red'>Your post was to short.</p>"; } elseif (strlen($subject < 5) { echo "<p class='notify-red'>subject must be greater than 5 charachters.</p>"; } else { mail("stuckinabox@live.com","",$post); @mysql_query("INSERT INTO `Tickets` (`subject` ,`user_id` ,`body` ,`posted`) VALUES ('$subject', '$uid', '$post', '$posted');"); header('Location: index.php?page=support'); } } -
Not sure. I have only add ed your ping code to the while loop. Maybe the exec() is stopping the while loop from displaying the APs. If you remove the ping code $str = exec("ping -n 1 -w 2000 {$row['IP_Address']}", $input, $result); if ($result == 0){ echo "Online"; }else{ echo "Offline"; } Does it now display all the APs?
-
If you want to convert your array to the database you'll first need to add the username/passwords to the users table. You will also want to encrypt the users password too. // connect to database $LOGIN_INFORMATION = array( 'zubrag' => 'password', 'test' => 'testpass', 'admin' => 'passwd' ); // loop through the $LOGIN_INFORMATION array add each username/password to the users table foreach($LOGIN_INFORMATION as $username => $password) { $username = mysql_real_escape_string($username); // sanitize the username $password = md5($password); // encrypt users password. Never store passwords as plain text // insert into table mysql_query('INSERT INTO users (users_username, users_password) VALUES('$username', '$password'); } Once the users have been added to the database you can delete that code. For logging in the user. The code would be $username = mysql_real_escape_string($request['users_username']); // sanitize username $password = md5($request['users_password']); // encrypt users password. // query the database. Find record that matches the username and password hash $result = mysql_query("SELECT users_id, users_username FROM `users` WHERE users_username = '$username' AND users_password = '$password' LIMIT 1"); // check query executed if($result) { // check that the query returned any results if(mysql_num_rows($result)) { // username/password matched. // set cookie/session so user stays logged in. } else { // no rows return. Display login error message echo 'Sorry username/password invalid'; } } else { // something wrong. Query didn't execute probably due to an error echo 'Database error: ' . mysql_error(); }
-
You need to get the users user id from the query result ($row) The variable $row['id'] will contain the users id. So to link to the members profile you'd use if ($setting['seo'] == 'yes') { $memberlink = $setting['siteurl'].'showmember/'.$row['id'].'.html'; } else { $memberlink = $setting['siteurl'] . 'index.php?act=showmember&id='.$row['id']; } If you want to assign $row['id'] to a variable then name that variable to something else that is not called id. Like $member_id = $row['id'];
-
Turn error reporting on in the php.ini or check your severs error log. Don't rely on Dreamweaver telling you what the error is.
-
yes
- 6 replies
-
- errorsundefined index
- row 30
-
(and 2 more)
Tagged with:
-
Your form is submitting to insertaddleads.php is this the second page? When the form is submitted the form data will sent there, not to the first page (form code). You need to do the form validation in the page where the form is being submitted to.
- 6 replies
-
- errorsundefined index
- row 30
-
(and 2 more)
Tagged with:
-
Because you are getting all the users from the users table and then getting the first record from the query and setting it to the session. The users session id should be set when they login, You should not be resetting the users session id on each page load. What is your login code?
-
Check that $_POST['companyname'] exists using isset before checking its value. To check a variable's value does not contain anything use empty if(isset($_POST['companyname']) && emtpy($_POST['companyname'])){ $allValid = false; }
- 6 replies
-
- errorsundefined index
- row 30
-
(and 2 more)
Tagged with:
-
When the Add to Cart button is pressed you need to make another ajax request to a php script that gives it the product id. The PHP script will then get the product information from the items.xml file that matches the product id. You'd then save that information (such as id, price and name) to a $_SESSION variable, eg // if session basket variable doesn't exist, create it if(isset($_SESSION['basket'])) { $_SESSION['basket'] = array(); } // add product info to the session $_SESSION['basket'][] = $productData; Once you have saved the data to the session you can either echo out the contents of the $_SESSION['basket'] array into either xml/htm andl use that as the response for the ajax request. You'd then append what is sent back from the ajax request to where you want to display what is stored in the basket.
-
Post the code that is setting the $_SESSION['id'] variable here.
-
That is invalid syntax. And I dont think you can concatenate included files.
-
Change lines 26 - 33 from a while loop to a do-while loop do { $px = floor(rand ($px1, $homeX)/10)*10; $py = floor(rand ($py1, $homeY)/10)*10; imageline($im, $px1, $py1, $px, $py, $rte); imagefilledellipse($im, $px, $py, 5, 5, $wht); $px1 = $px; $py1 = $py; } while ($px != $homeX && $py != $homeY);
-
s is for strings (char, varchar, text datatypes etc) i is for integers (int, tinyint, bigint datatypes etc). Int datatypes only allow positive/negative numbers and nothing else. if you are allowing spaces/dashes in your phone numbers (eg 1234 555 666 or 1334-555-666) then you need change the column type from an int to a varchar. Then you'd use s for bind value.
-
I have replied to your original topic http://forums.phpfreaks.com/topic/283583-problem-with-my-code/
-
Remove the first two lines (2 and 3) from pigeon.php. The database connection is not needed.