Jump to content

GKWelding

Members
  • Posts

    268
  • Joined

  • Last visited

About GKWelding

  • Birthday 10/09/1983

Contact Methods

  • Website URL
    http://www.in-the-attic.co.uk

Profile Information

  • Gender
    Male
  • Location
    UK

GKWelding's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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/
×
×
  • 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.