-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
The mysqli_query() function returns false on failure. Otherwise it returns true (for update queries). More information can be found here: http://php.net/manual/en/mysqli.query.php
-
Sorry, my brain has finally caught up. Update queries don't return a result set. So fetch_array isn't going to work. If you're looking to see how many rows were affected, you could use the function defined here: http://php.net/manual/en/mysqli.affected-rows.php Or you could just test that the query successfully executed.
-
Did you try using mysqli_error() to see if MySQL is reporting any errors? More information about the function can be found here: http://php.net/manual/en/mysqli.error.php
-
Hmm...I just noticed that get_stylesheet_uri() doesn't take any parameters. https://codex.wordpress.org/Function_Reference/get_stylesheet_uri It's just supposed to return the current theme's style sheet. Did you say that the following worked before you moved the style sheet? function nq_styles() { wp_enqueue_style('style', get_stylesheet_uri(style.css)); } Perhaps something has changed in WordPress and the documentation hasn't been updated.
-
You mentioned that the directory was up one level. Did you try something like the following: wp_enqueue_style('style', get_stylesheet_uri(../css/style.css));
-
I assume that the style sheet is stored in the same folder as your theme / child theme. If that's correct, have you tried using get_stylesheet_directory_uri()? More information can be found here: https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri
-
Also, I forgot to mention that you're using $link in the following line which I assume should be $connection: $name = mysqli_real_escape_string(mysqli $link, $_POST['name']);
-
To help with the debugging process, the following lines of code can be added to the top of your script: error_reporting(E_ALL); ini_set('display_errors', 1); When you're escaping the "user_level" variable, you're calling mysqil_real_escape_string() instead of mysqli_real_escape_string(). Here is your code: $user_level = mysqil_real_escape_string(mysqli $connection, $_POST['user_level']); In your calls to mysqli_real_escape_string(), you need to remove the "mysqli" references. The following, for example $email = mysqli_real_escape_string(mysqli $connection, $_POST['email']); Should be $email = mysqli_real_escape_string($connection, $_POST['email']); Also, you're using the $connection object before it's actually defined. The object is defined here, near the bottom of your script: $connection = mysqli_connect($dbhost_name, $username, $password, $database);
-
I figured this was probably the place to put this.
cyberRobot replied to ronc0011's topic in PHPFreaks.com Website Feedback
No worries; you're definitely not alone! It seems like every time I go through the forums, there at least one topic being duplicated multiple times. And some of those posters have similar stories as you. The Admins, Moderators, and Gurus work hard to remove the duplicate entries in a timely manor. -
I marked the topic has solved. For future reference, there is a "Mark Solved" button in lower-right hand corner of each reply box. You would of course click the button that correspondences with the reply that mostly closely answers the question(s).
-
Have you looked into looping through the results in $_FILES? Note that there are a number of examples in the User Contributed Notes found here: http://php.net/manual/en/features.file-upload.multiple.php#usernotes Basically, you could loop through the files and test the file name as you go. Whenever you run into a file name that isn't set to NULL, process the upload.
-
For what it's worth, many of the methods could be replaced with a single method that returns the requested variable. Here's a quick example of the direction you could go: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); class testClass { private $_portes = 'Portes'; private $_photo1 = 'Photo1'; private $_photo2 = 'Photo2'; private $_photo3 = 'Photo3'; public function getValue($variableName) { if(isset($this->$variableName)) { return $this->$variableName; } } } $car = new testClass; echo '<div>' . $car->getValue('_photo1') . '</div>'; echo '<div>' . $car->getValue('_portes') . '</div>'; $i = 2; echo '<div>' . $car->getValue("_photo$i") . '</div>'; ?>
-
Are you able to show what the photo1(), photo2(), photo3() functions look like?
-
Hmm...the code seems to work for me when I try the following: <?php class testClass { public function photo1() { print '<div>In photo1</div>'; } public function photo2() { print '<div>In photo2</div>'; } public function photo3() { print '<div>In photo3</div>'; } } $car = array(); $car[] = new testClass; $total_photos = 3; for ($i = 1; $i <= $total_photos; $i++) { echo call_user_func(array($car[0], "photo$i")); } ?> Do you know which version of PHP you're using? Is PHP set to show all errors and warnings? Note that you can add the following to the top of your script during the debugging process: error_reporting(E_ALL); ini_set('display_errors', 1);
-
It looks like you can use the call_user_func() function to dynamically name your class methods. You could try something like the following: <img onmouseover="preview.src=<?php echo call_user_func(array($car[0], "photo$i")); ?>.src" src="<?php echo call_user_func(array($car[0], "photo$i")); ?>" alt=""/>
-
If that doesn't work...which it probably won't, where does $car come from. Are you able to show the code where photo1() is defined? I imagine that it comes from a class definition. If that's correct, does the class have multiple methods like photo1(), photo2(), etc.?
-
Is it perhaps that this <img onmouseover="preview.src=<?php echo $car[0]->photo . $i . '()';?>.src" src="<?php echo $car[0]->photo1()?>" alt=""/> Needs to be changed to this <img onmouseover="preview.src=<?php echo $car[0]->photo . $i . '()';?>.src" src="<?php echo $car[0]->photo . $i . '()'; ?>" alt=""/>
-
As ginerjm mentioned, the PHP code shown is used to display the form. Do you have any code that processes the form submission? Basically, it would help to know where you're stuck? Which field(s) are you looking to validate? And what is considered valid? If you're looking for help on the basics of form validation and/or processing form submissions, there are many resources online: https://www.google.com/#q=php+form+validation
-
Perhaps the following will help: http://php.net/manual/en/features.file-upload.multiple.php
-
Try changing this <td><a href="customers.php?t=customer&id=<?php $id ?>"><?php echo $name; ?></a></td> To this <td><a href="customers.php?t=customer&id=<?php echo $id; ?>"><?php echo $name; ?></a></td>
-
For what it's worth, I've just gotten into the habit of pasting things into something like Notepad. Then copy and paste it into the forum. Turning off the WYSIWYG editor is probably a quicker way to go. But this forum is unlikely to be the only place where you'll have problems. I've had similar problems with many Content Management Systems, for example.
-
No problem, glad you figured it out! Note that I marked the topic as solved. If you need anything else, you can mark it as unsolved...or start a new topic.
-
How to use database column name rather than array position?
cyberRobot replied to bambinou1980's topic in PHP Coding Help
For what it's worth, here some more information about password hashing: http://php.net/manual/en/faq.passwords.php -
How to use database column name rather than array position?
cyberRobot replied to bambinou1980's topic in PHP Coding Help
You can use mysqli_fetch_assoc() instead of row: http://php.net/manual/en/mysqli-result.fetch-assoc.php -
Just to clarify, does $product->getMediaGallery() contain an array? If so, you should be able to use a foreach loop (or loops) to get all the 'url' parts.