-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
add a limit to joels query? $query = mysql_query("SELECT id, reg_id FROM `bidding_details` where bid_id='$bid_id' and sortbid = '1' and username='$username' ORDER BY bid_price DESC LIMIT 50"); I still don't see why your doing this, but I don't care, so whatever
-
im assuming this is the link you are talking about echo "...<a href='./index.php?p=blog&p=post&id=" . $id2 . "'>Read More</a><hr /> and its supposed to go to the blog page and show the full post. Well one problem I see is you define to p variables in the GET array. here: p=blog&p=post perhaps that should be different
-
$string = str_replace('\n', '', $string);
-
[SOLVED] Quick fix: Conditional statement with an array
mikesta707 replied to onceinabluemoon2's topic in PHP Coding Help
if you want to convert a numeric string into a number you can type cast it to an int like so $number = (int)$stringofNumber; or use the function intval $number = intval($stringofNumber); -
echo (!empty($search)) ? "<a href='uinfo.php?topic=$search&submit=Go!' style='text-decoration: none';>" : "<a href='uinfo.php'>"; this is using the ternary operator though. you could use an if statement if you wanted...
-
that usually means your query has failed. Echo the mysql_error() and post it
-
if you didn't back it up before hand, I don't think there is any way to back it up. Well at least you learned to always back your databases up. Do you have any backups at all?
-
if box[] is your HTML array, you could access each individual element like so echo $_POST['box'][5];//the sixth text box you could loop through the whole array like so for ($i = 0; $i < count($_POST['box']); $i++){ echo $_POST['box'][$i]; } //OR foreach($_POST['box'] as $box){ echo $box; }
-
a Where clause is a boolean condition. I have no clue what you are trying to do. What is your where clause supposed to do?
-
use a counter? $addz = mysql_query("SELECT * FROM Stacks WHERE username = 'Admin'")or die (mysql_error()); $i = 0; while($rowrun = mysql_fetch_array( $addz)) { $idz = $rowrun['id'] if ($i == 2){//or i = whatever you want. this would be the third run of the loop echo $idz; } $i++; }
-
the $this->whatever syntax is PHP's way of accessing class variables/methods within a class. PHP doesn't have a pointer type. in C++ it is similar to the this->whatever syntax, but in PHP you always must use $this->whatever when accessing attributes/methods inside a class, where in C++ you don't have to. It differs where in C++ this refers to the location in memory that the object resides (basically it is a pointer to itself) while in PHP it simply means it is referencing attributes or whatever in the class
-
you have to understand that PHP isn't the same as C++. Input (generally) comes from some sort of HTML form. Like Alex said, PHP does have support for command line input (the equivalent of cin) but generally, this isn't used, as PHP is mostly used for web applications. You can make desktop applications with PHP (assuming you have the interpreter on your computer/server) but PHP really shines when using it for websites. As far as ease of use, I find PHP much easier to use than C++, especially because all of PHP's different libraries can be used once they are installed without having to include header files every time. However, C++ is an incredibly powerful language. Really, picking a language is all about the task at hand. For a desktop application, C++ is definitely the winner, however PHP is much "better" with web applications. By better, I don't necessarily mean more efficient, but easier to use, and more geared towards web applications.
-
[SOLVED] Problem with getting to id of a post
mikesta707 replied to Noskiw's topic in PHP Coding Help
$id = $_GET['id']; //make sure you sanitize $id at some point $q = mysql_query("SELECT * FROM blog WHERE id='$id'" ); -
[SOLVED] Problem with getting to id of a post
mikesta707 replied to Noskiw's topic in PHP Coding Help
it is because here echo "...<a href='./index.php?p=blog&p=post&id='" . $id . "'>Read More</a></td></tr></table>\n"; you are closing your href attribute with the following href='./index.php?p=blog&p=post&id=' you dont need to surround get values with quotes. echo "...<a href='./index.php?p=blog&p=post&id=" . $id . ">Read More</a></td></tr></table>\n"; for the record, not many people care if you change what programming language you use. -
check the server error logs
-
try $q = "SELECT MAX(id) as maxID FROM users" $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); $max_id = mysqli_fetch_array($r); echo $max_id['maxID']; it would help if you also said what that code echoed
-
I may have found something that pertains to your problem. This can happen when magic quotes is turned on. If for example, you were to read a string in from a file, serialize it, and store it in a database, there is no way to then unserialize it: file contents: O'Reilly retrieved from file: O\'Reilly serialized: s:9:"O\'Reilly"; stored in db: s:9:\"O\'Reilly\"; after stripslashes(): s:9:"O'Reilly"; If you pass the magic-quoted value to serialize, it will choke on the escaped double quotes. If you run it through stripslashes(), unserialize will choke on the string-too-short problem. You could maybe work around it via regex, but... I worked around it by turning off magic_quotes. Perhaps this is more of a gotcha than a bug, but it would be nice to make unserialize smart enough to deal with the possibility.
-
I would say magic quotes is causing the problem. try stripslashes?
-
Make sure that the length of your password field in the table is long enough for md5 hashes. I usually use 64-128 character lengths for my password fields. This usually is what gets a lot of people, as if your string is longer than the max length, the string is truncated
-
remember to click solved on the bottom of the thread if your topic is solved
-
look into MySQL's MAX function http://www.w3schools.com/sql/sql_func_max.asp
-
oh so the text file would look like var1 = valu1 var2 = val2 etc.. if the value is a string, is it surrounded by quotes? theoretically, if the txt files are good, you could just append a $ symbol at the beginning, and add a semi colon at the end, and use EVAL, though depending on the source of the file, this could be dangerous. Can you give a very specific example of a test file
-
From PHP.Net In case the passed string is not unserializeable, FALSE is returned and E_NOTICE is issued. thus, you can just do if (!unserialize($variable)){ echo "Error Unserializing variable"; }
-
try checking out the PHP xml parser if its XML. for other formats, you will have to do different things, so what other formats might there be?
-
what does the text file look like? just a bunch of strings?