jazzman1
Staff Alumni-
Posts
2,713 -
Joined
-
Last visited
-
Days Won
12
Everything posted by jazzman1
-
As a web developer, you will often develop your scripts on unix (win) machines, web servers, database severs, ftp servers, mail servers and so on, so on. The best way for me and for everybody I guess is to start reading and understanding the error log files. Every web application above has a particular error directory on the real server. Go there, read the error message, if you don't understand it, go to the web site of this application or "google it" and try to find out what this error causes.
-
To keep the things pretty simple, let's say that our web site has only 1 page, represent by display.php file. Inside this file we want to include header.php, home.php and footer.php files. But, we also need to use a database in our project displaying some info inside the header and the home files. So, if we try to open db connections inside header and home files then to include them inside display.php file, we will get in trouble and may be after awhile we'll receive a message for too many connecions. To avoid it, we should open this db connection once on the top of the display file then just include all files that you need to be displayed.
- 16 replies
-
- max-connexion
- php
-
(and 1 more)
Tagged with:
-
It's a useful startup option for beginners in sql, which allows you to update(delete) rows only by specifying the key values that identify them, like in your example! So, I don't see nothing wrong in your database structure. I am out.
-
The rule is: You should open db connection only, when you need to communicate with DB server. Also, as kicken said, you must calling mysql_connect (or mysqli_connect) once. Php is a server side language, which means that every single line of the php code should be executed on the server first, before to send any outputs on the page (browser), unlike JavaScript for example. Php does not know, what is a header, sidebar, footer and so on, inside your html structure. Do you understand me? PS: Of course, that is true if you don't use output_buffering to cache the data, just to be clear
- 16 replies
-
- max-connexion
- php
-
(and 1 more)
Tagged with:
-
Your script, please!
-
Hm.....it's very weird! What SQL editor are you using to achive that? Anyways, it sounds like ( not sure) the SQL_SAFE_UPDATES is set up to ON. So, before to send an update command to the sql server, run that: SET SQL_SAFE_UPDATES=0;
-
"It still isnt working for me" does not help us! Did you get any errors? As developer, you need js debugging tools to help quickly discover the cause of an issue and fix it efficiently.
-
Wow......completely misread the line 43 of your first post last night. For sure, you should add the error checking logic that DavidAM has suggested and mac_gyver said above. Sorry about that.
-
Wampserver, starting PHP in my desktop
jazzman1 replied to moisesbr's topic in Other Web Server Software
Use "Alias Directive" under Apache. It allows documents to be stored in the local filesystem other than under the DocumentRoot folder. Never tested on windows machines! To obtain more information, check at docs of apache web site. -
The UPDATE SQL Statement is used to modify the existing rows (columns) in a table. I only see the column name without setting a column value in the statement above. So, the right syntax for this sql command should be something like: UPDATE table_name SET column_name_1 = column_value1, column_name_2 = column_value2 [WHERE some condition]
-
Hey BuildMyWeb, Are you sure that you're exactly running the same script? I don't think so So, what happens here? First of all, you should be aware how the programming languages work. Well, when JavaScript encounters the function name that you already called in the script, it completes the instructions only if that function has been found somewhere inside the <script></script> tags. When the instructions have all been performed, JavaScript comes back and process the remainder of the script. But, actually you're creating that function inside the if statement after you're calling it. So, the parser of the language stops executing the script and says - " Hey, I cannot find the name of this function" and returns a false result. That's all. This was a logical error! I highly recommend, you to wach this video created by Doug Crockford. Somewhere in the middle, he speaks about the proper way using of functions.
-
Assuming we have next web structure: / (web root, probably it called public_html in environment websites dev setup ) / work_dir (your project folder) /work_dir/display.php (your display page) /work_dir/.htaccess ( your .htaccess file) The easiest way to do that, is to provide URLs to users as expected. In that case you want to be ( home&foo=bar&hello=world ) So, go to the display.php file and create your fake URLs: display.php <?php if (isset($_GET['page'])) echo '<pre>'. print_r($_GET, true).'</pre>'; ?> <a href="./home&foo=bar&hello=world">Query String 1</a><br /> <a href="./jazz_music&foo=jazz&hello=jazzman">Query String 2</a><br /> <a href="./rOcK&foo=rock&hello=rockman">Query String 2</a><br /> .htaccess RewriteEngine On RewriteBase /work_dir RewriteRule ^/?([a-zA-Z_]+)&foo=([a-zA-Z_]+)&hello=([a-zA_Z_]+)$ display.php?page=$1&foo=$2&hello=$3 [L] The regExp accepts in the case above - letters (capital and small) and underscors, you can expand it as you wish.
-
No, it's not exactly the same. Take a look at my js code, where are the hide_select() and the hide_select() functions!
-
Did you try my sample above? I ran the code on my dev setup and looks fine. You have a php code, so you may get an error message(s) somewhere. Check this out: Debugging: A Beginner's guide
-
Check, if the checked attribute is true. So, the easiest way to achieve this (no tested) js code: <script> function show_hide( curr_page ) { // REGISTER page if( curr_page == "register" ) { var input_gc = document.getElementById("input_gc"); var input_sc = document.getElementById("input_sc"); if(input_gc.checked) hide_select(); if(input_sc.checked) show_select(); } // close if( curr_page == "register" ) function hide_select() { alert("h"); // procceed your logic } function show_select() { alert("s"); // proceed your logic } } // close function show_hide( curr_page ) </script> Radio buttons: <tr> <td class="form_label">Account Type:</td> <td> General Contractor: <input type="radio" name="acct_type" value="gc" id="input_gc" /> Subcontractor: <input type="radio" name="acct_type" value="sc" id="input_sc" /> </td> <tr><td><button onclick="show_hide('register')">Click me</button> </td></tr> </tr>
-
The error is self-explanatory! We don't know what type of data you want to be shown on the browser, you should tell us
-
Make sure that everything is speaking utf-8. Take a look at here.
-
@mac_gyver, every hidden directory or file is prefixed by a "." period symbol on the unix systems, so I completely exclude the possibility of server side error here. My best guess, without seeing any code is that he's trying to run a different database config file from other domain or sub-domain located on the same web root.
-
Find the file, which itself contains strings like these (if we are using the mysql library, of course): $conn = mysql_connect('old_db_server','old_db_user','old_db_pass'); $db_name = mysql_select_db('db_name'); and change to: $conn = mysql_connect('new_db_server','new_db_user','new_db_pass') or die(mysql_error()); $db_name = mysql_select_db('new_db_name') or die(mysql_error()); Also, if this db file is included inside other one, make sure that the path to this file is set properly! That's all you have to do for now.
-
You should provide us the code of the file dealing with DB server.
-
Wow.....you've gotta be kidding I'm still learning the English grammar Anyways, thank you so much for the faith!
-
Well, what's the name of the file generating that error message, above? Or this is from the server side error log file?
-
But the file "Loader.php" exists, right? So, what is the code at the line 104 or 105? PS: Also, to get a proper dir path to this file you would use the __DIR__ function (put it on the top of this file) : Loader.php echo __DIR__;
-
Try, header('Content-Type: text/plain; charset=utf-8'); $SearchTerms=array('Høstnatt på Fjellskogen', 'Langt Innpå Skoga', 'Den lille fløyten', 'Sølv'); // my array with search terms $string = "Den Lille Fløyten"; // The string to search $phrase = $SearchTerms[2]; // The term to search as part of an array echo $phrase."\n"; $phrase = preg_replace('/\s+/', '\s+', preg_quote($phrase)); $p = '/\b' . $phrase . '\b/ui'; $result = preg_match($p, $string); // This gives me FALSE (0)!!!!!!! echo $result; Results:
-
How to include user uploaded files to index.php
jazzman1 replied to Chatrapati's topic in PHP Coding Help
You cannot use the copy() function in that way. Check this out. Also, you should have to use some useful php functions helping you to debug your script. Debugging: A Beginner's guide