-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
No, an array is an array. A string is a string. Just that PHP allows you to treat a sting like an array. This is due to PHP loosely coupled nature.
-
Use regex on $image['image'] to get the value of the src attribute preg_match('~src="([^"]+)"~', $image['image'], $m); $image_src = $m[1];
-
PHP Code Not Returning Results from MYSQL Query
Ch0cu3r replied to CPGAmy's topic in PHP Coding Help
By pasting the query into the SQL field (Login to PMA, select database and then click the SQL tab). PMA should then list the results of the query -
Document root has nothing to do with the file upload. When the file is being uploaded it is stored in a temporary location on the server somewhere. It is the down to your PHP code move the uploaded file to its intended location. From the PHP manual on error code 3 Which means for some reason the client (the users browser) is not uploading file properly. Maybe the connection between the server and client is being timeout/lost?
-
You don't need the foreach loop. You'd use array_keys to get the keys and then use implode to build the column list. You'd then do a similar thing for values, whereby you'd use array_values to get the values and again use implode to build the values function smart_quote($val) { if(is_string($val)) $val = "'$val'"; // add quotes to string values } return $val; } $sql = 'INSERT INTO tblforensic (`'; $sql .= implode('`, `', array_keys($filtered)); // build column list $sql .= '`) VALUES ('. implode(',' array_map('smart_quote', array_values($values))) .')'; // build value list $result = $mysqli->query($sql);
-
Turn error reporting on, open the php.ini and make sure display_errors is set to on and error_reporting is set to E_ALL On line 18 - 24 you have a malformed if statement. Have left off the closing parenthesis for the condition and a opening { (curly brace) for the statement. On line 29 before the else you have left of the closing } (curly brace) for closing the if statement Refer to the manual for the proper structure for an if/esle The values for each case statement should be wrapped in quotes
-
Lesson learned is to always use the full opening php tag. Not all php configurations have short_open_tag enabled
-
I'd parse the data into a multidimensional array. So the row heading, will be used as the array key for the array containing the row data. Id assign each item in the row array with the corresponding column heading as the key. Example array structure Array ( //row 1 heading [apple] => Array ( // row data [apple] => 3 // column 1 value [blueberry] => -4 // column 2 value [carrot] => -1 [date] => 0.0002 [egg] => 0 [fish] => 0.0003 [garlic] => 0.006 [herring] => 1.00 [jasmin] => 9.62E-06 ) //column 2 heading [blueberry] => Array ( // row data [apple] => 0 [blueberry] => 0 [carrot] => 0 [date] => 0 [egg] => 0 [fish] => 0 [garlic] => 0 [herring] => 0 [jasmin] => 0 ) ...etc } To generate that array structure you'd use $handle = fopen('test.csv', "r"); // first row of the csv file contains the column headings $headings = fgetcsv($handle, 0, ","); $headings = array_filter($headings); // parse the the values into an array $data = array(); while (($row = fgetcsv($handle, 0, ",")) !== false) { // remove the row label from the row, use it as the arrat key later $row_label = array_shift($row); // set the corresponding heading as the key for the values in the row. $data[$row_label] = array_combine($headings, $row); } Now you can now easily get the intersecting value using $data[ $row_label ][ $column_label ] echo $data['apple']['blueberry']; // returns -4
-
Correction, I will then go an read ckeditors documentation
-
An example would be // list of emails with associated id $emails = array(); $emails['25457'] = "user1@email.com"; $emails['35685'] = "user2@email.com"; $emails['39697'] = "user3@email.com"; // email id passed in the query string? if(isset($_GET['id'])) { // retrieve the email id $email_id = intval($_GET['id']); // is there an email associated with that email id? if(isset($emails[ $email_id ])) { // retrieve the associated email $email = $emails[ $email_id ]; // do something with $email } } An example link would be like <a href="contact.php?id=25457">Contact me on Address 1</a>
-
Yes you can do that, but you'll need to manually edit the script each time to add/remove/change email addresses. Which is ok I suppose if you're only dealing with a vary small amount of addresses which wont change often.
-
How to add single quote instead of double quote?
Ch0cu3r replied to mark107's topic in PHP Coding Help
The single quotes are there (to see them you need to right click > view source). For some reason the browser is changing them to double quotes. -
How to add single quote instead of double quote?
Ch0cu3r replied to mark107's topic in PHP Coding Help
The code I posted is syntactically correct. You sure you tested it correctly? The \' will print a single quote echo 'One \'two\' three'; // outputs: one 'two' three echo "One 'two' three"; // outputs: one 'two' three -
Store the id and associated email address in a database. You'd then query the database and return the email address where the id matches, example query $mysqli->conect('localhost', 'user', 'pass', 'db'); $res = $mysqli->query($con, 'SELECT email FROM users WHERE id = ' . intval($users_id)); if($res && $res->num_rows > 0) { list($email) = $res->fetch_row(); // do something with $email (will contain the associated email address) }
-
$_SESSION['username']=$username; Not case sensitive
Ch0cu3r replied to slj90's topic in PHP Coding Help
Something else is causing the username to become lowercase. PHP wont change a variables value unless you tell it to. -
How to add single quote instead of double quote?
Ch0cu3r replied to mark107's topic in PHP Coding Help
The single quotes are not showing because you are using it as the string delimiter. If you want to print a literal single quote you'll need to escape it $xml .= '<programme channel=\'' .$channel. '\'>'; //OR $xml .= "<programme channel='" .$channel. "'>"; -
It is built into PHP you dont need to enable/install any extensions for it to work You can check it is available by running phpinfo() if lists dom and libxml then you should able to use DOMDocument object.
-
Use PHP's DOMDocument object to traverse through the xml structure, dont try parsing the xml structure yourself.
-
The problem then is most likely the .. at the start of the file path in your HTML. Just start your HTML file paths with a / instead css_includes.php <link type="text/css" rel="css/stylesheet" href="/css/reset.css"> ...etc <link type="text/css" rel="css/stylesheet" href="/css/shCoreDefault.css"> js_includes.php <script type="text/javascript" src="/js/XRegExp.js"></script> ...etc <script type="text/javascript" src="/js/core.js"></script>
-
Okay so is the file paths correct to your JavaScript and CSS files? Remember the file paths used in the HTML must be relative to your sites (current) url. Where as the file paths used in PHP are relative to where the script is located on the file system.
-
What do you mean? That SQL script should create two tables, called users and files For the script to create the tables you need to first make sure you are logged in to phpMyAdmin, then select your database where you want the tables to be created and then click on the Import tab. Browse to the .sql file in your computer and then click the Go button. The two tables should now be created in your database.
-
Tell us what you see when you right click > view source, Check to make sure the HTML output by your PHP code is correct (The PHP code should not be present).
-
They wont need the salt, they'll just spam your login form.
-
If you know how to store the users username in the session then you should be able to work out how to do it for a the first name too.
-
Change this part of the regex (ext(ension)?: to (ext(ension)?:?