
trq
Staff Alumni-
Posts
30,999 -
Joined
-
Last visited
-
Days Won
26
Everything posted by trq
-
Far from correct. Currently the modify() method expects at least one argument. Your overloaded method didn't that is why you where getting the error. What Andy-H's code does is declares that your modify() also expects an argument, however he has also set a default value for this argument (of false) making it now optional.
-
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=357181.0
-
That is just generally poor coding unless it's a very simple script. Unfortunately however, I don't believe poor coding skills can be improved by simply throwing tools at the problem and hoping for the best.
-
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=357187.0
-
This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=357188.0
-
My preference is to not introduce some other syntax for no real benefit. If your designers need to learn some template engine syntax why not have them learn some basic PHP? You generally don't need more than simple loops and conditionals. At my work we have massive scale applications and no issue with mixing minimal PHP and markup. It's easier and quicker. I really just don't see the point in adding another layer.
-
There are ways of separating your business logic from your markup that don't involve the overhead of a template engine. The mvc pattern comes to mind. Why throw some other syntax variant into the mix when you can achieve the same results using a little PHP?
-
Have you executed this query from within MySql to see what it might look like? Your query will return something like: [pre] +------------------+---------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+---------------------+------+-----+---------------------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | somefield | varchar(255) | NO | | | | +------------------+---------------------+------+-----+---------------------+----------------+ [/pre] Armed with this information you can see to use: $sql = "SHOW FIELDS FROM apartmentoUsers"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo $row['Filed'] . '<br />'; echo $row['Type'] . '<br />'; echo $row['Null'] . '<br />'; echo $row['Key'] . '<br />'; echo $row['Default'] . '<br />'; echo $row['Extra'] . '<br />'; } } } Of course, $row is just an array, so you could also have looped through it also. $sql = "SHOW FIELDS FROM apartmentoUsers"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { foreach ($row as $val) { echo $val . '<br />'; } } } }
-
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=357163.0
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=357165.0
-
And this query would be no different.
-
This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=357168.0
-
This previous reply might help you. http://www.phpfreaks.com/forums/index.php?topic=356177.msg1685225#msg1685225
-
file location stored in database retrieval to html
trq replied to carterlangley's topic in PHP Coding Help
Any ideas? You haven't told us the problem. -
Strings need to be surrounded by quotes in sql, integers do not. Complex structures (like arrays) should also be surrounded by {curly braces} when within double quoted strings. $result = mysql_query("UPDATE new_line_test SET data = '{$_POST['datatoenter']}' WHERE ID = 1") Also, you should not place user data directly into your queries as it leads to all sorts of security issues. Run $_POST['datatoenter'] through mysql_real_escape_string first. $data = mysql_real_escape_string($_POST['datatoenter']); $result = mysql_query("UPDATE new_line_test SET data = '$data' WHERE ID = 1")
-
This is exactly what nl2br was designed to do. New lines are invisible characters. Try it and see.
-
This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=357112.0
-
You should do your comparisons in your query, not in PHP.
-
What is the problem? The only part your wrong about is that nl2br doesn't replace newlines with <br /> tags, it simply inserts <br /> tags after newlines.
-
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=357109.0
-
It type casts $comments to an array. ie; Forces $comments to be of type Array. See http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting
-
We are not here to supply people with code. Do you have an actual question?