Jump to content

GKWelding

Members
  • Posts

    268
  • Joined

  • Last visited

Everything posted by GKWelding

  1. Well there's your issue, the array has only 1 element. your inner foreach is working fine.
  2. jQuery ajax will initialise data as an empty string because the CSS file does not contain an overall block level element. I would change it to var script = document.createElement("script"); script.type = "text/css"; script.src = "/css/style.css"; document.body.appendChild(script);
  3. First, CODE tags make things much clearer. Second, just before foreach ($response->records as $record) { Can you do a var_dump($response->records);die(); and post the output here.
  4. For a start, what does the line if(!isset($_GET['c_id'])) do? Nothing by the looks of it. And your error message is correct. $c_id isn't defined anywhere. I would replace the above line with $c_id = $_GET['c_id']; And that page will work. However, the mix of PHP and display code isn't nice, if I were you I'd do some reading on design patterns.
  5. <?php $connect=mysql_connect("localhost","root",""); mysql_select_db("bank",$connect) or die ("could not select database"); $account_number=''; $tran_id=''; if(isset($_POST['account_number'])) $account_number=$_POST['account_number']; else $account_number=''; //getting the faulty transaction $query = "select * from transaction WHERE account_number='$account_number'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); //Correcting the account table if(strtolower('transaction_type')=="deposit"){ $operator = "-"; }else{ $operator = "+"; } $query= "UPDATE account SET `account_balance`=(`account_balance`".$operator.$row['transaction_amount'].") WHERE account_number='$account_number'"; mysql_query($query) or die(mysql_error()); //deleting the faulty transaction $query = "DELETE from transaction WHERE account_number='$account_number'"; mysql_query($query) or die(mysql_error()); ?> Also, TBH, now you really should be using mysqli rather than mysql.
  6. not quite sure wtf is going on there, line 5 looks fine to me. check that line 5 is exactly like it is in your php file as that shouldn't be throwing any kind of error. And I say PHP errors aren't cryptic but wait until you get an 'Unexpected: T_PAAMAYIM_NEKUDOTAYIM'... Meaning you have an extra : somewhere...
  7. it means it's getting a string when it wasn't expecting it, the error messages in php aren't really that cryptic, you may have deleted a quote or semi-colon by accident? If you post the code again I'll spot it in 2 seconds flat, lol.
  8. ok, on line 93 in front of is_array($signup_interest) put isset($signup_interest) &&
  9. Does it happen to give you a line number for that error?
  10. The code below should now work, notice the use of the isset construct in the if statements. <? include('includes/config.php'); $is_error = 0; if (isset($_POST['task']) && $_POST['task'] == 'singup_do') { $signup_username = $_POST['user_username']; $signup_password = $_POST['user_password']; $signup_pwd_again = $_POST['user_password_again']; $signup_email = $_POST['user_email_address']; $signup_interest = $_POST['signup_interest']; if ($signup_username == ''){ $is_error = 1; $signup_username_msg = 'The username cannot be left blank'; } if ($signup_password == ''){ $is_error = 1; $signup_password_msg = 'Password field cannot be left blank'; } if ($signup_pwd_again == ''){ $is_error = 1; $signup_pwd_again_msg = 'Password again field cannot be left blank'; } if ($signup_email == ''){ $is_error = 1; $signup_email_msg = 'Email cannot be left blank'; } if ($signup_email != '' && !validateEmailAddress($signup_email)) { $is_error = 1; $signup_email_msg = 'Incorrect E-mail address'; } if (!is_array($signup_interest) || count($signup_interest)==0){ $is_error = 1; $signup_interest_msg = 'Please select atleast one interest'; } //EMAIL ADDRESS VALIDATION if ($signup_password!='' && $signup_pwd_again!='' && $signup_password != $signup_pwd_again) { $is_error = 1; $error_msg = 'Passwords don\'t match'; } //USERNAME DUPLICATION VALIDATION if (!$is_error && $signup_username!='' && !checkUsername($signup_username)) { $is_error = 1; $signup_username_msg = 'Username already taken, please enter another'; } if (!$is_error) { $signup_interest_ids = ( is_array($signup_interest) ? implode(',', $signup_interest) : '' ); $users_insert = "INSERT INTO users SET user_id='', user_username = '{$signup_username}' , user_password='{$signup_password}', user_email_address = '{$signup_email}', users_interests='{$signup_interest_ids}', user_active='Y', user_date_added=NOW()"; mysql_query($users_insert); header('Location:login.php?signup=success'); } } ?> <html> <head> <title>Register</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> </head> <body > <div align="center"><BR><BR><BR> <div style="width:50%; "> <form name="frmSignup" action="sign_up.php" method="post"> <input type="hidden" name="task" value="singup_do"> <table width="100%" border="0" cellspacing="4" cellpadding="4" align="center"> <? if (isset($error_msg) && $error_msg!='') {?> <tr><td> </td><td class="tahoma10rednormal"><?=$error_msg?></td></tr> <? }?> <tr><td width="20%" valign="top">Username : </td><td><input name="user_username" type="text" class="textfield" size="35" value="<?=$signup_username?>"/><? if (isset($signup_username_msg) && $signup_username_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_username_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Password : </td><td><input name="user_password" type="password" class="textfield" size="35" value="<?=$signup_password?>"/><? if (isset($signup_password_msg) && $signup_password_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_password_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Password (again): </td><td><input name="user_password_again" type="password" class="textfield" size="35" value="<?=$signup_pwd_again?>"/><? if (isset($signup_pwd_again_msg) && $signup_pwd_again_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_pwd_again_msg. '</span>' ; } ?></td></tr> <tr><td valign="top">Email address: </td><td><input name="user_email_address" type="text" class="textfield" size="35" value="<?=$signup_email?>"/><? if (isset($signup_email_msg) && $signup_email_msg!='') { echo '<BR><span class="tahoma10rednormal">' . $signup_email_msg. '</span>' ; } ?></td></tr> <tr><td colspan="2" ><b>Interests:</b><? if (isset($signup_interest_msg) && $signup_interest_msg!='') { echo ' <span class="tahoma10rednormal">' . $signup_interest_msg. '</span>' ; } ?></td></tr> <tr><td colspan="2"> <? $categories = getCategories(); $categories_count = count($categories); if (is_array($categories)) { $cat_counter=0; ?> <table width="80%" border="0" cellspacing="4" cellpadding="4"> <? foreach($categories as $cats) { if ($cat_counter==0 || ($cat_counter%4) == 0) echo '<tr>'; $chk_selected = ''; if (is_array($signup_interest) && in_array($cats['id'], $signup_interest)) $chk_selected = "CHECKED"; ?> <td><input type="checkbox" name="signup_interest[]" value="<?=$cats['id']?>" <?=$chk_selected?>><?=$cats['text']?></td> <? if ($cat_counter==$categories_count || ($cat_counter%4) == 3) echo '</tr>'; $cat_counter++; } ?> </table> <? } else { echo 'No interest added yet.'; } ?> </tr> <tr> <td> </td> <td><input type="submit" name="submit_btn" value="Sign Up"> <input type="button" name="cancel_btn" value="Cancel" onClick="window.location.href='index.php'"></td> </tr> </table> </div> </div> </body> </html>
  11. If I remember rightly, this will work... $className = 'pattern'.$patNum; $action = new $className();
  12. The php file attached works fine. It was because you where using braces (the {}) to evaluate the variables in the SQL string. I've gotten rid of these and also added in some variable security in the form of mysql_real_escape_string. I have tested this and it definitely does work fine. I did the first test with your code and managed to replicate the error, removing the braces and concatenating the string instead work perfectly, I then just added in the variable escaping as it's bad practice not to. [attachment deleted by admin]
  13. does article_title work? also, without seeing the initial SQL query and table structure we can't really help you much?
  14. to stop it doing mod-rewrite on css, js and images files you need to add the following 2 rewrite conditions to your htaccess file. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d So your new htaccess will look like this... RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|design) RewriteRule ^(.*)$ index.php/$1 [L] However, to be honest, I would just use the htaccess given here... http://codeigniter.com/wiki/mod_rewrite/
  15. for a start, if this isn't just a copy paste error, then this function is wrong... function detailTopic(){ if(isset($_POST['content']{ //if there is a reply to a post mysql_query("UPDATE topics SET Replies=Replies+1") //works fine } else{ //no reply, just show all posts mysql_query("UPDATE topics SET Views=Views+1") //fires 2 times per page load .. ?!?!? //show posts //show reply window, posts to forum.php?goto=innertopic&&content=whateverTheUserTyped } } it should be function detailTopic(){ if(isset($_POST['content'])){ //if there is a reply to a post mysql_query("UPDATE topics SET Replies=Replies+1") //works fine } else{ //no reply, just show all posts mysql_query("UPDATE topics SET Views=Views+1") //fires 2 times per page load .. ?!?!? //show posts //show reply window, posts to forum.php?goto=innertopic&&content=whateverTheUserTyped } }
  16. http://www.php.net/manual/en/ref.ftp.php
  17. you're using an incorrect mix of single and double quotes, do either one or the other, not both: url_setopt($ch, CURLOPT_POSTFIELDS,'name='. $name .'&email='. $email .'&macs='.$mac_addresses.'&serial='.$serialnumber); or url_setopt($ch, CURLOPT_POSTFIELDS,"name=$name&email=$email&macs=$mac_addresses&serial=$serialnumber");
  18. $newfile = 'C:\xampp\htdocs\new\old\'.$_POST['argument']; OR $newfile = "C:\xampp\htdocs\new\old\$_POST['argument']"; notice the use of single and double quotes, basic php.
  19. However, your problem is that you're double encoding the $data array, more specifically get rid of $data['groups'] = stripslashes(json_encode($groups)); and replace with $data['groups'] = $groups; then change $output = stripslashes(json_encode($data)); to $output = json_encode(stripslashes($data));
  20. ok, what makes you think it's incorrectly formatted?
  21. Try this, you should see a small improvement in the rate. Using mysql_result is slower than using mysql_fetch_row, mysql_fetch_array and mysql_fetch_assoc. Also, try not to do SELECT * if you can get away with it. If this helps can you post back here with the increase in rate as I'm very interested. $get_data = mysql_query('SELECT id, tweets FROM raw_data WHERE processed = \'0\' ORDER BY `raw_data`.`id` ASC') or trigger_error('RawDataQueryFailed: ' . mysql_error()); while($data = mysql_fetch_array($get_data)){ // continously fetch data $row_id = $data['id']; $tweet = json_decode($data['tweets']); if ($tweet->user->screen_name != '' && $tweet->text != ''){ $date = date('U'); $user = mysql_real_escape_string($tweet->user->screen_name); $twt = mysql_real_escape_string($tweet->text); $prof_img = $tweet->user->profile_image_url; echo 'Username: '.$tweet->user->screen_name.'<br>'; echo 'Tweet: '.$tweet->text.'<br>'; echo 'Date: '.$date.'<br>'; echo 'Link: '.$link.'<br>'; echo '<img src="'.$tweet->user->profile_image_url.'">'; echo '<hr>'; // insert data into db if ($link != 'not found'){ // Check if user exists in db // $usr_chk = mysql_query('SELECT id FROM users WHERE username = '.$user); if (mysql_num_rows($usr_chk) == '0'){ // Create new user $sql = mysql_query('INSERT INTO users (username, profile_img) VALUES ('.$user.', '.$prof_img.')'); $u_id = mysql_insert_id(); } else { $result = mysql_query('SELECT id FROM users WHERE username = '.$user.' LIMIT 1'); if($result) { $u_id = mysql_fetch_row($result); $u_id = $u_id['id']; $sql = mysql_query('UPDATE users SET profile_img = '.$prof_img.' WHERE id = '.$u_id); } } // Record link // $sql = mysql_query('SELECT id FROM link WHERE url = '.$link.' LIMIT 1'); if (mysql_num_rows($sql) == '0'){ // Create new entry $sql = mysql_query('INSERT INTO link (url, count, long_url, first_seen, last_seen) VALUES ('.$link.', \'1\', '.$long_url.', '.$date.', '.$date.')'); $link_id = mysql_insert_id(); } else { // Update old Entry $result = mysql_query('SELECT id FROM link WHERE url = '.$link.' LIMIT 1'); if($result) { $link_id = mysql_fetch_row($result); $link_id = $link_id['id']; $sql = mysql_query('UPDATE link SET count = (count + 1), last_seen = '.$date.' WHERE url = '.$link); } } // Insert Tweet // $sql = mysql_query('INSERT INTO tweets (tweet, date, link_id, username) VALUES ('.$twt.', '.$date.', '.$link_id.', '.$user.')'); $tweet_id = mysql_insert_id(); // Create relationship $sql = mysql_query('INSERT INTO relationships (username, tweet_id, link_id) VALUES ('.$user.', '.$tweet_id.', '.$link_id.')'); } } mysql_query('DELETE FROM raw_data WHERE id = '.$row_id.' LIMIT 1'); } // end foreach
  22. quite simply, $_SESSION['votes'] isn't an array. do a print_r on the $_SESSION['votes'] array key and see what you have there. If it's empty but should be an array then you may need a check around the in_array function like: (is_array($_SESSION['votes']) && !in_array($_SERVER['REMOTE_ADDR'].$url2, $_SESSION['votes'])?
  23. Just some background as to why this would cause it to miss the first entry. calling mysql_fetch_array before the while loop sets array pointer to the first key in the array, which is your first value of 'buffer'. Then doing the while loop, because you do not reset the pointer location, starts the while from $array['1'] rather than array['0']. Doing the following will prove this: $info = mysql_fetch_array( $data ); Print "This is the error point and your missing value ".$info['0']; Print "<b>Products:</b></br> "; while($info = mysql_fetch_array( $data )){ Print "" .$info[0]. "</br> "; }
  24. Nevermind, spotted your error. Change your code to the following. Make sure you copy all of it. you don't need the initial $info = mysql_fetch_array(); that's what's screwing up your results. <?php $data = mysql_query("SELECT name FROM products") or die(mysql_error()); Print "<b>Products:</b></br> "; while($info = mysql_fetch_assoc( $data )){ Print $info['name']. "</br> "; } ?>
  25. Change to: while($info = mysql_fetch_assoc( $data )){ print_r($info); } and then post here what the output of that is.
×
×
  • 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.