PHP - Not Finding Entry In Sql Database - Help Please
Hi
I'm very much a newbie to PHP and am struggling with a registration and login problem. The registration part is fine - the password is emailed out fine, I check the database and the entry is there, the password is encrypted. but when the user tries to log in.... if (mysql_num_rows($result) == 0) .... it returns 0? and the access denied page is shown. I'm thinking it is something to do with the sql database encryption? I'm completely lost here and would appreciate some guidance Thanks in advance Jan Similar TutorialsMy query is not finding the last recieptnum entry, it is finding the number 9 everytime for some odd reason. Im trying to incrementally increase this each time a reciept is created. $getreceiptnum = mysql_query("SELECT receiptnum FROM accounting WHERE agency = '$agency' ORDER BY receiptnum DESC LIMIT 1") or die(mysql_error()); $recieptarray = mysql_fetch_array($getreceiptnum); $recieptnum = $recieptarray['receiptnum']; echo $recieptnum; i'm trying to get the username of the last person to enter something into a database table,and display it an html table. the problem is, the query is failing, and i get the error "Table 'forum.posts' doesn't exist". if in the error message "forum" means the name of the database, and "posts" the name of the table, there is something wrong, as they both exist. the code i'm using is below $list = "SELECT * FROM section_main ORDER BY section_title"; $result = mysql_query($list) or die ("Query failed"); $numofrows = mysql_num_rows($result); for($j = 0; $j < $numofrows; $j++) { $row = mysql_fetch_array($result); echo "<tr><th>". $row['section_title']."</th></tr>"; $query2 = "SELECT * FROM section_sub WHERE section_id = '".$row['section_id']."' ORDER BY section_sub_title"; $result2 = mysql_query($query2) or die("Select Error :" . mysql_error()); $numofrows2 = mysql_num_rows($result2); for($i = 0; $i<$numofrows2; $i++){ $row2 = mysql_fetch_array($result2); echo "<tr><td><a href='display_forum.php?id={$row2[section_sub_id]}'>".stripslashes($row2[section_sub_title])."</a></td><td>"; $new = mysql_query("Select * FROM posts WHERE section_sub_id = '".$row2['section_sub_id'] . " ' ") or die ("Select Error :" . mysql_error()); //this is where the error message is from $lastpost = mysql_fetch_assoc($new); echo $lastpost['username']; echo"</td></tr>"; } } i've checked that the names of the tables and fields in the queries are correct, but i cant think of anything else that might be wrong. any help would be great. I am designing a mmorpg guild site, and decided to make a coordinate database. A user will enter their own coords, x and y, and the 10 closest coords to them will be displayed. I need help doing this. My table is: id coordx coordy alliance region I am using $_GET to retrieve the user's input. so $_GET['mex'] $_GET['mey'] Thanks in advance for your help. I'm working on an old cms I built a few years ago and for some reason my Delete page isn't working. It has to be something simple I'm overlooking. The database connection is made just above this code and is pulling the thumb and title listed by id. When I push delete I'm getting the cmd=delete&id=2 passed on so something is up with my last if statement (I think). Here is the code: if(!isset($cmd)) { //display all the news $result = mysql_query("select * from verizon order by id"); //run the while loop that grabs all the news scripts while($r=mysql_fetch_array($result)) { //grab the title and the ID of the enws $title=$r["title"];//take out the title $id=$r["id"];//take out the id $thumb=$r["thumb"]; echo "<div id='delete'> <table> <tr> <td width='350px'><strong>$title</strong></td><td><a href='verizondelete.php?cmd=delete&id=$id'> Delete</a></td> </tr> <td colspan='2' align='center'><img src='../upload/verizon/$thumb'></td> </table> </div><br />"; } } if($cmd=="delete") { $sql = "DELETE FROM verizon WHERE id='$id'"; $result = mysql_query($sql); echo "<h1 style='text-align:center;'>deleted!</h1>"; } } ?> Hi everyone, I need a little bit of help finishing off my code. Ive managed to get this far. Code: [Select] <?php mysql_connect("") or die ("Not Connected to MYSQL"); echo "</br>"; mysql_select_db("") or die ("Not Connected to DB"); // Database Connection stuff $partialNumber = $_POST['partialNumber']; // Post the Partial number $partialNumber = strtoupper($partialNumber); $numberSearch = mysql_query("SELECT * FROM product_option_value_description WHERE name LIKE '%$partialNumber%'") or die (mysql_error()); // Query to select the key number //Query to get product ID // $productId = "SELECT product_id FROM product_option_value_description"; //Query to get product ID // while ($keyNumber = mysql_fetch_array($numberSearch)) { $id = $keyNumber['product_id']; // Query for the images // $query = "SELECT image FROM product WHERE product_id = '$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result) or die(mysql_error()); $query2 = "SELECT product_option_id FROM product_option_value WHERE product_id = '$id'"; $result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2) or die(mysql_error()); $query3 = "SELECT product_option_value_id FROM product_option_value WHERE product_id = '$id'"; $result3 = mysql_query($query3); $row3 = mysql_fetch_array($result3) or die(mysql_error()); ?> <div> <br /><br /> Key Number: <? echo $keyNumber['name']; ?></a> <form action="http://www.co.uk/teststore/index.php?route=checkout/cart" method="post" enctype="multipart/form-data" id="product"> <br /> <table style="width: 100%;"> <tr> <td> Colour: <select name="option[<? echo $row2['product_option_id']; ?>]"> <option value="<? echo $row3['product_option_value_id']; ?>"></option> </select></td> </tr> </table> <div class="content"> Qty: <input type="text" name="quantity" size="3" value="1" /> <input type="hidden" name="product_id" value="<? echo $id; ?>" /> <input name="submit" type="submit" value="Add to Cart" /> </div> </form> <? echo $row3['product_option_value_id']; ?> </div> <br /> <img height="150" width="150" src='http://www.co.uk/teststore/image/<? echo $row['0']; ?>'/> <? } ?> And here is my SQL Table code. Code: [Select] product_option_value_id product_option_id product_id 599 302 49 598 302 49 589 297 42 588 297 42 So as you can probably tell, it is a search program that looks for products on a shopping cart. The products will have different option values, and the php script will grab the option values and echo them in a form to post back to the cart to add the product to the basket. The problem is that the "product_option_value_id" can have lots of different values, but my code echos only the first one it finds. So when I click the add to cart button, it will only add the first option value for the product it finds. For some reason I am having a hard time explaining this, so I hope someone can help me. Thanks for looking. Hello all. I am finishing up a paypal IPN php script and was wondering how I can take some data and cut some of it off before I enter it into the mysql database? Heres what I have. $payment_date = HH:MM:SS DD Mmm YY, YYYY PST This comes from paypal. I want to in my code take that and automatically cut off the HH:MM:SS part. So my question is, how can I take a known piece of data and automatically trim the first 9 spots off of it? Something like: $payment_date = HH:MM:SS DD Mmm YY, YYYY PST Minus 1 thru 9 of $payment_date = $result $payment_date2 = $result Any help? Thanks! Hey guys, im new around here, and i have just recently started teaching myself PHP, by looks of this site i seem very experienced but im eager to learn I seem to get an error with this code. The point of this code is to look into my database and pull out all entries with the first name _____ (whatever the user inputs) Error: Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\searchans.php on line 12 Code: Filename:search.php Code: [Select] <html> <form action='searchans.php' method='POST'> First Name: <input type='text' name='firstname'><br> <input type='submit' value='Search'> </form> </html>Code: Filename:searchans.php Code: [Select] <?php $firstname = $_POST['firstname']; $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } $query = mysql_query("SELECT * FROM Persons WHERE FirstName='$firstname'"); while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName'] . " " . $row['Age']; echo "<br />"; } ?> Hi, Would someone please give me some assistance on how to display random products from my database I need to display a maximum of 6 images and there link in two rows of 3 so; [image] [image] [image] [image] [image] [image] and each image would have something like; <a href="<? echo $row['product_link'] ?>"><img src="<? echo $row['product_image'] ?>"/></a> but i don't know how to display these at random and make sure only 6 appear at a time. Thanks for any help, hope you understand what im trying to explain No errors come up when I run this but it just doesn't delete the entry. <? $rec = $_POST['stock']; if (!$rec){ die ('Please eneter a stock number'); } $link = mysql_connect("xxxx","xxx","xxx"); mysql_select_db('wadkin', $link) or die( "Unable to select database"); mysql_query("DELETE FROM 'wadkin'.'stocklist' WHERE 'stocklist'.'Stock Number' = $rec") or die ('Query failed'); mysql_close($link); ?> Can someone please correct, (btw I have also tried... "DELETE FROM stocklist WHERE 'Stock Number' = $rec") Hello PHPfreaks members, I want my PHP coding to read/fetch my database's first attribute/entry like the first number of the client in that first row and then fetch it to be shown on PHP so that it will show '1'. How would I do that? Here's the table of my example database (MySQL) I know the command to select the line via the database is this: SELECT * FROM CUSTOMER WHERE CUST_NO=1; hey guys, I'm getting a problem uploading my csv file to mysql database, the code on the top half just makes sure that I don't import data that I don't want into the database, numbers that are too high or too low on certain rows, and the second half is importing the array that I create from the csv file into the database however I'm getting the following error
Duplicate entry 'Array' for key 'strProductCode'
Now I've never had this error before and I'm not sure what's causing it so any help would be very much appreciated
$data = array(); if (($handle = fopen("stock.csv", "r")) !== FALSE) { while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) { // only add rows to the array where the 4th column value is greater than or equal to 10 if(($row[3] >= 10 && $row[4] >= 5) OR ($row[3] >= 0 AND $row[4] > 5)){ if($row[4] < 1000){ $data[] = $row; } } } foreach ($data as &$value) { mysql_query("INSERT INTO tblProductData (intProductDataId, strProductCode, strProductName, strProductDesc, strProductStock, strProductCost, dtmDiscontinued, dtmAdded, stmTimestamp) VALUES(null, '$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', 'time', 'added', 'time') ") or die(mysql_error()); } } Hello there,
I would be really grateful if someone could advice please, how do I find this pesky entry in the 'db' table? This is what it says,
"Found an entry in the 'db' table with empty database name; Skipped." MySQL version is 5.5.40
I am pretty much stuck on it. Does it mean the table's name is db? Plus, I am not sure I understand the wording of it too. The empty database name cannot exist by default as it won't allow you to create a database without a name in the first place. I do not even know how and where to begin to look for it because honestly speaking I do not quite understand the phrase itself, because it does not make much sense to me. I would really highly appreciate it if someone could explain and suggest how do I find the... "whatever it says" :-) and to fix it. Many thanks in advance!
P.S. I know this warning may easily and safely be ignored as it is of minor inconvenience and not that important the more so as MySQL is working fine but my curiosity is just running wild for two reasons: 1. I do not really understand what this warning message is trying to tell me and 2. How do I find and adjust it to turn off the warning.
Simple regular things as running myisamchk -r *.MYI on where MySQL is did not help as this warning is actually out of scope of what myisamchk can fix.
And yes, I've Googled it long enough but couldn't seem to come up with anything reasonable solutions.
Thankful for any suggestions / pointers / assistance / comments at all.
Edited by Klaipedaville, 29 October 2014 - 06:17 AM. I'm creating a newsletter and the unsubscribe isn't deleting the database entry like I'm asking it to. Everything else works fine, it even successfully says the user has been removed, but it doesn't actually delete the database entry. I've spent two days trying to figure out why. Here's the code:
Newsletter sign up: <?php //DB Connect Info $servername = ""; $database = ""; $username = ""; $password = ""; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } /*$createTable = $conn->prepare ("CREATE TABLE IF NOT EXISTS email_user ( id int(11) NOT NULL AUTO_INCREMENT, email varchar(200) NOT NULL, hash varchar(250) NOT NULL, PRIMARY KEY (id) )"); $createTable->execute(); */ function input_security($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $email = input_security($_POST['email']); $insertData = input_security($insertData); if(isset($_POST['submit'])) { extract($_POST); if($email!="") : $email=mysqli_real_escape_string($conn,$email); $emailval = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/'; if(preg_match($emailval, $email)) : $db_check=$conn->query("SELECT * FROM email_user WHERE email='$email'"); $count=mysqli_num_rows($db_check); if($count< 1) : $hash=md5($email.time()); $link = '/unsubscribe.php?key='.$hash; // Change your domain $fetch=$conn->query("INSERT INTO email_user(email,hash) VALUES('$email','$hash')"); $to="$email"; //change to ur mail address $strSubject="Maintenance Fee Relief, LLC | Email Subscription"; $message = '<p>Thank you for subscribing with us.</p>' ; $message .= '<p>Click here to unsubscribe your email : <a href="'.$link.'">unsubscribe</p>' ; $headers = 'MIME-Version: 1.0'."\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n"; $headers .= "From: info@"; $mail_sent=mail($to, $strSubject, $message, $headers); $msg_sucess="Your request has been accepted!."; else : $msg="This $email email address is already subscribe with us."; endif; else : $msg="Please enter your valid email id"; endif; else : $msg="Please fill all mandatory fields"; endif; } ?> <div class="newsletter-sign-up-header-form"> <div id="logerror"><?php echo @$msg; ?><?php echo @$msg_sucess; ?></div> <form method="post"> <span><input type="email" name="email" placeholder="Email Address - Join Newsletter" class="newsletter-sign-up-header-email" required></span> <span><button name="submit" value="submit" title="Submit" class="newsletter-sign-up-header-submit-button">Submit</button></span> </form> </div> <?php //DB Connect Info $servername = ""; $database = ""; $username = ""; $password = ""; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } ?> <?php if(@$_GET['key']!=""): $hash=mysqli_real_escape_string($conn,$_GET['key']); $fetch=$conn->query("SELECT * FROM email_user WHERE hash = '$hash'"); $count=mysqli_num_rows($fetch); if($count==1) : $row=mysqli_fetch_array($fetch); $conn->query("DELETE email_user WHERE id='$user_id'"); $msg="Your email id unsubscribe with us"; else : $msg="Please click valid link."; endif; else : header("Location:404.php"); endif; ?> <!doctype html> <html lang="en"> <head> <title>Unsubscribe</title> </head> <body> <div align="center"> <h2><?php echo $msg; ?></h2> <a href="https://www.--.com">--.com</a> </div> Quote
I'm making a login area for the hotels in a booking system, where they enter their hotels' information, policy, and room rates but I want to make the room rates when it appears for clients, it appears with a percentage (commission) added to what the Hotel representative will enter So what's better? it should be added in the admin area of the hotels and gets saved in the database with the commission or I should add it in the booking form so the code grab the rate from the database, multiply it by the percentage and echo the result? I am trying to set up a item entry page form.png: Upon submission it shows unsuccessful even though I have checked the fields on mysql table and seem to be good am I missing something? Code: [Select] <form action="" method="post" enctype="multipart/form-data" name="Product_Entry"> <TABLE> <TR> <TD>Product ID</TD><TD><input name="SKU_ProductID" value="<?php if (isset($_post['SKU_ProductID'])) echo $_POST['SKU_ProductID']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Merchant SKU ID</TD><TD><input name="SKU_MerchSKUID" value="<?php if (isset($_post['SKU_MerchSKUID'])) echo $_POST['SKU_MerchSKUID']; ?>" type="text" size="18" maxlength="30" /></TD> </TR> <TR> <TD>Game Title</TD><TD><input name="Game_Title" value="<?php if (isset($_post['Game_Title'])) echo $_POST['Game_Title']; ?>" type="text" size="40" maxlength="40" /></TD> </TR> <TR> <TD>Platform</TD><TD><input name="Platform" value="<?php if (isset($_post['Platform'])) echo $_POST['Platform']; ?>" type="text" size="20" maxlength="20" /></TD> </TR> <TR> <TD>Genre</TD><TD><input name="Genre" value="<?php if (isset($_post['Genre'])) echo $_POST['Genre']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Weight</TD><TD><input name="Weight" value="<?php if (isset($_post['Weight'])) echo $_POST['Weight']; ?>" type="text" size="7" maxlength="7" /></TD> </TR> <TR> <TD>Supplier</TD><TD><input name="Supplier" Value="<?php if (isset($_post['Supplier'])) echo $_POST['Supplier']; ?>" type="text" size="25" maxlength="25" /></TD> </TR> <TR> <TD>Suppliers Price</TD><TD><input name="Supplier_Price" value="<?php if (isset($_post['Supplier_Price'])) echo $_POST['Supplier_Price']; ?>" type="text" size="10" maxlength="12" /></TD> </TR> <TR> <TD>Cashback</TD><TD><input name="Cashback" value="<?php if (isset($_post['Cashback'])) echo $_POST['Cashback']; ?>" type="text" size="6" maxlength="8" /></TD> </TR> <TR> <TD>Cashback Amount</TD><TD><input name="Cashback_Amount" value="<?php if (isset($_post['Cashback_Amount'])) echo $_POST['Cashback_Amount']; ?>" type="text" size="7" maxlength="11" /></TD> </TR> <TR> <TD><input type="hidden" name="submitted" value="true"/></TD><TD><input name="Submit" type="submit" value="Add_Product" /></TD> </TR></form></TABLE> <?php # Product Entry $page_title = 'Product Entry'; if (isset($_POST['Submit'])) { $errors = array(); if (empty($_POST['SKU_ProductID'])) { $errors[] = 'Please enter Product ID.'; } else { $sid = trim($_POST['SKU_ProductID']); } if (empty($_POST['SKU_MerchSKUID'])) { $errors[] = 'Please enter Merchant SKU.'; } else { $mid = trim($_POST['SKU_MerchSKUID']); } if (empty($_POST['Game_Title'])) { $errors[] = 'Please enter Game Title.'; } else { $gt = trim($_POST['Game_Title']); } if (empty($_POST['Platform'])) { $errors[] = 'Please enter Platform.'; } else { $pl = trim($_POST['Platform']); } if (empty($_POST['Genre'])) { $errors[] = 'Please enter Genre.'; } else { $ge = trim($_POST['Genre']); } if (empty($_POST['Weight'])) { $errors[] = 'Please enter Weight.'; } else { $we = trim($_POST['Weight']); } if (empty($_POST['Supplier'])) { $errors[] = 'Please enter Supplier.'; } else { $sup = trim($_POST['Supplier']); } if (empty($_POST['Supplier_Price'])) { $errors[] = 'Please enter Supplier Price.'; } else { $sp = trim($_POST['Supplier_Price']); } if (empty($_POST['Cashback'])) { $errors[] = 'Please enter Cashback %.'; } else { $cb = trim($_POST['Cashback']); } if (empty($_POST['Cashback_Amount'])) { $errors[] = 'Please enter Cashback Amount.'; } else { $cba = trim($_POST['Cashback_Amount']); } if (empty($errors)) { require_once ('connect.php'); [b]$q = "INSERT INTO `Products` (`SKU_ProductID`, `SKU_MerchSKUID`, `Game_Title`, `Platform`, `Genre`, `Weight`, `Supplier`, `Supplier_Price`, `Cashback`, `Cashback_Amount`) VALUES ('$sid', '$mid', '$gt', '$pl', '$ge', '$we', '$sup', '$sp', '$cb', '$cba')"; $r = @mysql_query ($dbc, $q); if ($r) { // If it ran OK. // Print a message: echo '<h1>Thank you!</h1> <p>Product Inserted!</p><p><br /></p>'; } else { // If it did not run OK. // Public message: echo '<h1>System Error</h1> <p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; // Debugging message: echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } // End of if ($r) IF. mysqli_close($dbc); // Close the database connection.[/b] // Include the footer and quit the script: include ('includes/footer.html'); exit(); } else { echo '<H1>Error!</H1> <p class="error">The Following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } } ?> If there is anything else needed let me know Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: Code: [Select] VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help. I am using php to upload a file to my server, and at the same time inserting the files name and url into my mysql database.
$sql = "UPDATE uploads SET name = '$name', url='$target_path'"; $statement = $dbh->prepare($sql); $statement->execute();This is working, however, when I upload a new file, rather than making a new entry in my database, it just overwrites the first one. I'm quite new at mysql so was wondering how I would make it add new entrys instead of overwriting the current one? Hi I have a file, that is copied from other files. All other files work perfectly. But, for some reason this one is throwing back an error. I've been over it so many time, but can't see whats wrong. Error: Fatal error: Call to undefined method stdClass::save() in /home/p/o/powtest/web/public_html/admin/lib/ajax_php/add_interests.php on line 28 add_interests.php Code: [Select] <?PHP require_once("../../../includes/initialize.php"); $flag = 0; $ID = $_POST['ID']; $type = $_POST['type']; $category = $_POST['category']; $interest = $_POST['interest']; $expInt = explode("\n", $interest); $DMOD = date('Y-m-d'); $TMOD = date('H:i:s'); $check_entry = Admin_interest::if_exists(clean_input_value($category)); if($check_entry == 0){ $new_category = Admin_interest::make($ID, clean_input_value($category), clean_input_value($type), $DMOD, $TMOD); if($new_category && $new_category->save()){ $CID = $new_category->id; $flag = 1; } } foreach($expInt as $expInts){ $check_entry = Admin_interests_sub::if_exists($CID, clean_input_value($expInts)); if($check_entry == 0){ $new_interest = Admin_interests_sub::make($ID, $CID, clean_input_value($expInts), $DMOD, $TMOD); if($new_interest && $new_interest->save()){ $message = 'Thank You: Your list Has Been Saved'; }else{ $message = "Sorry, There was an error"; } } } echo $message; ?> Class: Code: [Select] <?PHP require_once(LIB_PATH.DS.'database.php'); class Admin_interests_sub { protected static $table_name="admin_interests_sub"; protected static $db_fields = array('id', 'category_id', 'interest_sub', 'dateMod', 'timeMod'); public $id; public $category_id; public $interest_sub; public $dateMod; public $timeMod; public static function make($ID, $category_id, $interest_sub, $DMOD, $TMOD){ if(!empty($interest_sub)){ $interest = new Admin_interests_sub(); $interest->id = (int)$ID; $interest->category_id = (int)$category_id; $interest->interest_sub = $interest_sub; $kw->dateMod = $DMOD; $kw->timeMod = $TMOD; return $kw; }else{ return false; } } protected function attributes(){ $attributes = array(); foreach(self::$db_fields as $field){ if(property_exists($this, $field)){ $attributes[$field] = $this->$field; } } return $attributes; } protected function sanitized_attributes(){ global $database; $clean_attributes = array(); foreach($this->attributes() as $key => $value){ $clean_attributes[$key] = $database->escape_value($value); } return $clean_attributes; } public function save(){ return !empty($this->id) ? $this->update() : $this->create(); } public function create(){ global $database; $attributes = $this->sanitized_attributes(); $sql = "INSERT INTO ".self::$table_name." ("; $sql .= join(", ", array_keys($attributes)); $sql .= ") VALUES ('"; $sql .= join("', '", array_values($attributes)); $sql .= "')"; if($database->query($sql)){ $this->id = $database->insert_id(); return true; }else{ return false; } } public function update(){ global $database; $attributes = $this->sanitized_attributes(); $attribute_pairs = array(); foreach($attributes as $key => $value){ $attribute_pairs[] = "{$key}='{$value}'"; } $sql = "UPDATE ".self::$table_name." SET "; $sql .= join(", ", $attribute_pairs); $sql .= " WHERE id=".$database->escape_value($this->id); $database->query($sql); return ($database->affected_rows() == 1) ? true : false; } public function delete(){ global $database; $sql = "DELETE FROM ".self::$table_name." "; $sql .= "WHERE id=".$database->escape_value($this->id); $sql .= " LIMIT 1"; $database->query($sql); return ($database->affected_rows() == 1) ? true : false; } } ?> Any help finding this bug will be a big help. Thanks Okay I'm done with searching for answers, working on this preg_match for about 3 hours now.
I'm looking for "($0.01/$0.02 USD)" in a string. The needle might be slighty different. Possible strings that I might look for is: (€xx.xx/€xx.xx EUR) where the EUR can be changed into USD, including its signs. hi there all i need the code that adds the url to a page like in the new forums cheers.
you get a image of that website and the url of the page
can anyone help please
thank you
like if i type www,google.com <<< you get a image and link automaticly..
Edited by php-real-degree, 15 September 2014 - 05:07 PM. |